Regular Expressions
-
Hello everybody! :-) I am working on a little program and I was wondering if somebody could kindly offer me some help on using Regex? Here's a scenario, let's say that I have a HTML file... I want to be able to find any text inside a HTML tag. For example: Find meeee! or; la la lalaaaa But, the text between the HTML tags may contain symbols, letters, numbers etc, so is there a simple way to use Regex to find any text inside a HTML tag, extract/copy it, and perform an action, and then move onto the next match?: 1. Find match. 2. Copy or Extract the match. 3. Perform an action, like save match to file (which I know how to do). 4. Find next match, and repeat process. I would greatly appreciate any help I can get on this. Lots of thanks in advance and thanks for taking the time to read this pretty long question. :-) P.S. I wouldn't have posted this message, but I have tried MSDN and Google, read articles and tutorials but just can't get any of the snips I wrote to work. Cheers, Jay. foreach( inch on Jason ) { Girlfriend.IsHappier(); }
-
Hello everybody! :-) I am working on a little program and I was wondering if somebody could kindly offer me some help on using Regex? Here's a scenario, let's say that I have a HTML file... I want to be able to find any text inside a HTML tag. For example: Find meeee! or; la la lalaaaa But, the text between the HTML tags may contain symbols, letters, numbers etc, so is there a simple way to use Regex to find any text inside a HTML tag, extract/copy it, and perform an action, and then move onto the next match?: 1. Find match. 2. Copy or Extract the match. 3. Perform an action, like save match to file (which I know how to do). 4. Find next match, and repeat process. I would greatly appreciate any help I can get on this. Lots of thanks in advance and thanks for taking the time to read this pretty long question. :-) P.S. I wouldn't have posted this message, but I have tried MSDN and Google, read articles and tutorials but just can't get any of the snips I wrote to work. Cheers, Jay. foreach( inch on Jason ) { Girlfriend.IsHappier(); }
well i am assuming you know how to use the regex class and loop matches so ill attempt at a regex string for you... "^<.*>.*<.*>$" then with you match you could do a subtring...
string text = match.Substring(match.IndexOf('>') + 1, match.LastIndexOf('<'));
...maybe that will do it for you
Life goes very fast. Tomorrow, today is already yesterday.
-
Hello everybody! :-) I am working on a little program and I was wondering if somebody could kindly offer me some help on using Regex? Here's a scenario, let's say that I have a HTML file... I want to be able to find any text inside a HTML tag. For example: Find meeee! or; la la lalaaaa But, the text between the HTML tags may contain symbols, letters, numbers etc, so is there a simple way to use Regex to find any text inside a HTML tag, extract/copy it, and perform an action, and then move onto the next match?: 1. Find match. 2. Copy or Extract the match. 3. Perform an action, like save match to file (which I know how to do). 4. Find next match, and repeat process. I would greatly appreciate any help I can get on this. Lots of thanks in advance and thanks for taking the time to read this pretty long question. :-) P.S. I wouldn't have posted this message, but I have tried MSDN and Google, read articles and tutorials but just can't get any of the snips I wrote to work. Cheers, Jay. foreach( inch on Jason ) { Girlfriend.IsHappier(); }
All RegEx help you want -> http://www.regular-expressions.info/[^]
Yusuf Can I help you?