Jesper Christensen
asked on
Help with regular expression
hi guys.
I am trying to get an regular expression to grab the text "EE", but it dosen´t work:
Can somebody help?
My regex:
<b>Name:</b>[\s\S](.*?)
The code:
<span class="content">
<b>Name:</b>
EE
</span>
I am trying to get an regular expression to grab the text "EE", but it dosen´t work:
Can somebody help?
My regex:
<b>Name:</b>[\s\S](.*?)
The code:
<span class="content">
<b>Name:</b>
EE
</span>
what happens if you change [\s\S] to \s*
Set multiline option in your Regex as true as well.
ASKER
ozo: nothing :/
EaswaramP: How can i enable this option?
EaswaramP: How can i enable this option?
Try
<b>Name:</b>[\r\l]+(.*?)[\ r\l]+<
<b>Name:</b>[\r\l]+(.*?)[\
Hi,
GetText:\s*[\'\"]([^\'\"]+ )[\'\"] If you use .NET's named capture from System.Text.RegularExpress ions, the regex can be modified as follows:
GetText:\s*[\'\"](?<mytext >[^\'\"]+) [\'\"] ...and your targeted text is in the match group "mytext"
Please check the below our experts links comments
https://www.experts-exchange.com/questions/24465093/RegEx-to-extract-text-between-two-given-HTML-Tags.html.
Also check it for learning Simple examples demonstrating the [ regexp ] command in the below link.
http://wiki.tcl.tk/989
Regards
Guvera
GetText:\s*[\'\"]([^\'\"]+
GetText:\s*[\'\"](?<mytext
Please check the below our experts links comments
https://www.experts-exchange.com/questions/24465093/RegEx-to-extract-text-between-two-given-HTML-Tags.html.
Also check it for learning Simple examples demonstrating the [ regexp ] command in the below link.
http://wiki.tcl.tk/989
Regards
Guvera
ASKER
andrewssd3: It dosen´t work.
OMG I hate reg exp :/
Why hasent somebody made a tool, which allow me to mark sa text in a html context and press "Build expression" :)
OMG I hate reg exp :/
Why hasent somebody made a tool, which allow me to mark sa text in a html context and press "Build expression" :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@EaswaranP
@bongii
I offer a slight tweak to FernandoSoto's pattern, just to eliminate the trailing whitespace on the captured text:
Set multiline option in your Regex as true as well.Multiline would serve no purpose here. Singleline would be the intended modifier.
@bongii
Why hasent somebody made a tool, which allow me to mark sa text in a html context and press "Build expression" :)Well there is, but you have to pay for it: http://www.regexmagic.com/
I offer a slight tweak to FernandoSoto's pattern, just to eliminate the trailing whitespace on the captured text:
<b>Name:</b>\s+(\S+)
You can use this pattern as well:
(?m)(?<=<b>Name:</b>[^\S]+ )[^< ]+
(?m)(?<=<b>Name:</b>[^\S]+
@Shahan_Developer
The multiline modifier serves no purpose in your pattern. Also, isn't it a bit complicated to say whitespace as "[^\S]" when "\s" would suffice?
The multiline modifier serves no purpose in your pattern. Also, isn't it a bit complicated to say whitespace as "[^\S]" when "\s" would suffice?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The pattern posted by Fernando works perfect. Thanks.
<b>Name:</b>\s+([^<]+)
Can you also help me get the link from this context:
<a class="link" title="test" href="http://www.link.com">test</a>
I need the output :http://www.link.com
<b>Name:</b>\s+([^<]+)
Can you also help me get the link from this context:
<a class="link" title="test" href="http://www.link.com">test</a>
I need the output :http://www.link.com
<b>Name:</b>\s(.*)
@bongii:
Do you need this:
EE----------------> EE along with spaces
or:
EE ------------------>EE without spaces
My pattern gives "EE" not " EE".
Do you need this:
EE----------------> EE along with spaces
or:
EE ------------------>EE without spaces
My pattern gives "EE" not " EE".
ASKER
Ahh ok Shahan. Thx :)
What about this:
<a class="link" title="test" href="http://www.link.com">test</a>
I need the output :http://www.link.com
What about this:
<a class="link" title="test" href="http://www.link.com">test</a>
I need the output :http://www.link.com
My pattern gives "EE" not " EE".Funny.... So does mine. *sigh*