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>
Jesper ChristensenProgrammerAsked:
Who is Participating?
 
Fernando SotoConnect With a Mentor RetiredCommented:
Hi bongii;

Try this regex pattern, it should give you what you need.

<b>Name:</b>\s+([^<]+)

Fernando
0
 
ozoCommented:
what happens if you change [\s\S] to \s*
0
 
Easwaran ParamasivamCommented:
Set multiline option in your Regex as true as well.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Jesper ChristensenProgrammerAuthor Commented:
ozo: nothing :/

EaswaramP: How can i  enable this option?
0
 
andrewssd3Commented:
Try

<b>Name:</b>[\r\l]+(.*?)[\r\l]+<

0
 
guveraCommented:
Hi,

GetText:\s*[\'\"]([^\'\"]+)[\'\"] If you use .NET's named capture from System.Text.RegularExpressions, 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
http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_24465093.html.

Also check it for learning Simple examples demonstrating the [ regexp ] command  in the below link.
http://wiki.tcl.tk/989

Regards
Guvera
0
 
Jesper ChristensenProgrammerAuthor Commented:
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" :)
0
 
käµfm³d 👽Commented:
@EaswaranP
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+)

Open in new window

0
 
Shahan AyyubSenior Software Engineer - iOSCommented:
You can use this pattern as well:

(?m)(?<=<b>Name:</b>[^\S]+)[^< ]+
0
 
käµfm³d 👽Commented:
@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?
0
 
Shahan AyyubConnect With a Mentor Senior Software Engineer - iOSCommented:
Ohh!

>>>The multiline modifier serves no purpose in your pattern
I decided to work on it from different point of view and left (?m) intact (checked with online tester) so could not trace :S

>>>isn't it a bit complicated to say whitespace as "[^\S]"
Right. but still it will not produce wrong result.

The patten should be:
(?<=<b>Name:</b>\s+)[^< ]+

it gives "EE"
0
 
Jesper ChristensenProgrammerAuthor Commented:
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
0
 
ozoCommented:
<b>Name:</b>\s(.*)
0
 
Shahan AyyubSenior Software Engineer - iOSCommented:
@bongii:

Do you need this:
          EE----------------> EE along with spaces
or:
EE ------------------>EE without spaces

My pattern gives "EE" not "          EE".
0
 
Jesper ChristensenProgrammerAuthor Commented:
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
0
 
käµfm³d 👽Commented:
My pattern gives "EE" not "          EE".
Funny....   So does mine.  *sigh*
0
 
Shahan AyyubSenior Software Engineer - iOSCommented:
@bongii

Check this pattern:

(?<=<a[\sa-zA-z="]+href=")([^>]+)(?=".*</a>)

gives:
http://www.link.com
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.