Question Locked

Regex To Exract Text Inbetween 2 Selected Points ?

0 helpful
0 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

RegExp Exps (Regular Expression Experts), ;)

What is the regex to extract your desired text inbetween 2 tags such as the opening html tag and the closing.
Should work for other tags too such as javascript, xml, dhtml, css, etc.

Imagine that, I'm on a webpage that looks like this in the source code:

Article

Regex is too complicated to learn!
Why on earth could not the inventors build it simpler so it is easier to learn ?
Oh boy, oh boy!

Now imagine, I want to extract the text inbetween the .
and likewise extract inbetween and .
Now, what is the regex to do that ?
Ok, there maybe regex to extract the title and another to extract the meta keywords and another to extract the meta descriptions and so on from a page.
But, I ain't interested in the specific regex. I just need to learn the general one that is capable of extracting text inbetween 2 points. In the regex, I should point out (1st param) what the starting point is. And, point out (in the 2nd param) what the ending point is.
And, in this thread, I ain't interested in extracting text inbetween tags either. I'm actually interested in extracting text from inbetween 2 points whether the starting point is some tag (html, javascript, etc.) or mere simple text.
Another example ....

[B]My name is Bert. What is your's ?. What ! You don't have a name ? You mus be kidding ?[/B]
Imagine in this example, the starting point is the 2nd "[B]is[/B]" and the ending point is the 2nd "[B]?[/B]".
And so, the regex should allow me to pick the starting and ending point and any offsets.

If there is a php function that does this then you can mention this too. But, mention it under "OFF TOPIC".

0 replies

No replies were posted before this discussion closed.

This discussion is closed to new replies.