|
As I mentioned I mostly do C++, so I have only tried the trial version of resharper. I did like it, and to tell you the truth, everyone I know likes it But you really should give it a go yourself - the trial gives you 10 days to make up your mind.
|
|
|
|
|
Hi, I need to strip out text from a big file and my condition is:
I need to strip out text from below
<div class="a">apple</div>
<p> </p>
<p>red delicious</p>
<div class="b">banana</div>
<p> </p>
<p>riped banana</p>
<div class="c">chives</div>
<p> </p>
<p>fresh green chives</p>
to below
'apple', 'red delicious'
'banana', 'riped banana'
'chives', 'fresh green chives'
so that i can enter each of them to database. I would really appreciate if you could please provide me a regex that could do this. thanks for your help!!!
please note the content of the text is a concatination of multiple html pages.
|
|
|
|
|
repost[^], and no PRE tags once again ==> no help
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
The string you presented is a valid XML (root element is missing).
If performance is not an issue, first add a root element and then you can use XmlDocument or XmlReader to extract the information you needed.
|
|
|
|
|
no only the text i have provided you is valid. the content of the entire csv files has text like
----1----
my contents..
----2----
my content2..
...
...
so could you please help how to extract the data i want?
i have this regex that seem to work to get text between div tag
?<=\<div class=""middlead""\>).*?(?=\</div\>
but i need to get description of apple too. i tried to use below code
string fName = @"data.txt";
StreamReader testTxt = new StreamReader(fName);
string allRead = testTxt.ReadToEnd();
testTxt.Close();
Regex rx1 = new Regex(@"(?<=\<p\> \</p\>).*?(?=\</p\>)", RegexOptions.Singleline);
MatchCollection matches1 = rx1.Matches(allRead);
StreamWriter sw = new StreamWriter(@"realdata.txt");
int count = 0;
foreach (Match match in matches1)
{
sw.WriteLine(count.ToString());
sw.WriteLine(match.ToString());
foreach (Match match1 in matches1)
{
sw.WriteLine(match1.ToString());
}
count++;
}
sw.Close();
}
but some how regex rx1 is not only giving text that i want but its doing greedy matching and try to match everything that has
could you please help as to how can i extract the description of those products.
|
|
|
|
|
Once again, html IS xml. Just use Linq-To-XML to parse it - using regex is a WASTE OF TIME. It's easy - really. All you have to do is man-up and do some frakking research. It's just a few lines of code.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
please note the descript content doesnt have ID so i cant really use dom. any suggestions as to have to get text inside with no id?
|
|
|
|
|
Hi,
Please use below Regex Pattern to get your result.
.*?>([a-zA-Z0-9].*?)<
Which will return the collection of
apple
red delicious
banana
riped banana
chives
fresh green chives
Please let me know if you have any doubt.
|
|
|
|
|
Hi thanks but the text i provided was just an example real text looks something like below and i need a regex for this one below
<p> </p>
<p>red delicious.</p>
<div class="central"><p> </p>
<FORM action="product.asp" method="post" >
<INPUT type="hidden" name="ss" value="3">
<INPUT type="hidden" name="xx" value="xx">
<INPUT type="hidden" name="yy" value="yy">
<input type="image" src="./main/apple.png" value="Click here" />
</form><p> </p>
<p> </p>
<p>riped pear.</p>
<div class="central"><p> </p>
<FORM action="product.asp" method="post" >
<INPUT type="hidden" name="ss" value="3">
<INPUT type="hidden" name="xx" value="xx">
<INPUT type="hidden" name="yy" value="yy">
<input type="image" src="./main/pear.png" value="Click here" />
</form><p> </p>
this one is not working for me as its getting more text than i need
<pre>
(?<=\s\s\<p\>&nbsp;&nbsp;&nbsp;\</p\>\n\t\t\s\s\<p\>).*?(?=\\</p\>\n\t\t\s\s\<div class=""central""\>
</pre>
modified on Wednesday, January 27, 2010 6:14 PM
|
|
|
|
|
not sure why my below regex fails in visual studio editor
(?<=\<p\> \</p\>\n\t+:b+).*(\n\t+:b+\<div class="central"\>)
please note \t+ and :b+ are added because there is exactly 2 tab spaces and 2 white spaces in between the matching text. if I only use
<p\> \</p\>\n\t+:b+ it highlights the preceeding text of the matching text. not sure why by select between group is not working in visual studio. I am running out of ideas please help???
|
|
|
|
|
I tested using regexbuddy
for text
"apple"
with my regex
(?<=a).*?(?=e)
returns "ppl"
now i want to get text in between using below regex
(?<=\<p\> \</p\>).*?(?=\<div class="central"\>)
<p> </p>
<p>red delicious.</p>
<div class="central"><p> </p>
<FORM action="x.asp" method="post" >
<INPUT type="hidden" name="oradvertiser" value="3">
<INPUT type="hidden" name="xx" value="test">
<INPUT type="hidden" name="xy" value="test">
<input type="image" src="./main/apple.png" value="Click here" onmouseout="this.style.border='5px solid silver';" />
</form><p> </p>
<p> </p>
<p>riped pear.</p>
<div class="central"><p> </p>
<FORM action="x.asp" method="post" >
<INPUT type="hidden" name="or" value="3">
<INPUT type="hidden" name="xx" value="test">
<INPUT type="hidden" name="xy" value="test">
<input type="image" src="./main/pear.png" value="Click here" onmouseout="this.style.border='5px solid silver';" />
</form><p> </p>
<p>dummy text</p>
but its not giving me "red delicious" and "riped pear"
could you please help?
|
|
|
|
|
this works
<p>&nbsp;&nbsp;&nbsp;</p>\s+<p>(?<content>.*?)</p>\s+<div class="central">
|
|
|
|
|
good
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
try to use
labelname.refrsh()
after the line u changed text property of the lable
|
|
|
|
|
Hi All ,
I can make application for communication between two pc in same network .But I want to make this communication in following case ,
I have two PC PC1 and PC2 want to communicate them,
PC1 is in network in one company 1, and pc2 is in network of company2 ,PC1 have ip 192.168.1.5 and its router add is 122.xxx.xxx.123 similarly PC2 have ip 192.168.1.5 and its router ip is 123.xxx.xxx.78.
then how should i connect them .
Thank You.
|
|
|
|
|
You can't! At least one of them must be visible to the other.
The best solution is to use a server which is visible to both.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Hi all, i asking about marshalling, what it is means, and why we need it???
I face this statment at some code, but i don't know exactly what it means ..;
< // Marshal pointer into a struct
PcapUnmanagedStructures.pcap_if pcap_if_unmanaged =
(PcapUnmanagedStructures.pcap_if)Marshal.PtrToStructure(nextDevPtr,
typeof(PcapUnmanagedStructures.pcap_if));
>
|
|
|
|
|
I'm no expert so this is a rough overview. I'm sure Luc will be along soon to offer a much better description!
Marshalling is data transformation. Things in the managed world are different from the unmanaged world and marshalling takes care of transforming the data so we can pass it between the two worlds.
Unmanaged code often uses pointers to pass the references to values rather than the values themselves. These pointers are marshalled back to managed code to an IntPtr. To get the actual value pointed to, we can use the Marshal class to transform the data at the given reference to a structure as in your example.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
That is just fine, no way to improve on it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Hello
I have an list array of strings that I would like to display in a list box.
List<string[]> Param = new List<string[]>();
if I do
for (int index = 0; index < Param.Count; index++)
{
listBox1.Items.Add(Param[index][0]+"\t"+Param[index][1]);
}
The output is all skewed depending on what the length of the first string is.
How can I make this a multicolumn listbox, writing each string to the appropiate colummn?
Thank you in advance.
|
|
|
|
|
You should either use a ListView (in Detail view) or a DataGridView as they are multicolumn controls.
Alternatively you could use a fixed width font and calculate the correct position of the second column based on the longest length of the first string - fugly but it will work!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I tried creating a DataGridView
But when I set the
dataGridView1.DataSource = Param;
it only list the information about the Param structure and not the data inside.
Are you able to show me how to add to the DataGridView data?
Thank you in advance
|
|
|
|
|
See Alex's answer below
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
try this:
for (int index = 0; index < Param.Count; index++)
{
listBox1.Items.Add(Param[index][0]+"\t\t"+Param[index][1]);
}
note:
i use this method before to show lists but it is so hard to get the data back from it so try datagriadview there is more options you can do with it.
|
|
|
|
|
for (int index = 0; index < Param.Count; index++)
{
datagridview.Rows.Add(Param[index][0],Param[index][1]);
}
but you should add col. before you do that:
datagridview.coluomn.Add("1","1");
datagridview.coluomn.Add("2","2");
|
|
|
|