Regexp simple question

A

Arun Kumar

Hi,
I'm using the following regexp to capture a particular string from a
japanese website content.

/<ul id="ownerProfile" class="owner">.*?<li>([^<]*?)<\/li>/m

The following is the match result.

女性 /

Is there a way I can remove the slash('/') from my result by modifying
the above regular expression.


N. B. gsub can be used but I want to know whether there it can be
achieved by modifying the above regexp

Please help.

Thanks
Arun
 
S

Srijayanth Sridhar

[Note: parts of this message were removed to make it a legal post.]

Your boss doesn't like gsub?

Try

/<ul id="ownerProfile" class="owner">.*?<li>([^<\/]*?)<\/li>/m


That should work, but it won't work for a case where you have / separating
something in the inner text.

Jayanth
 
P

Phlip

Arun said:
I'm using the following regexp to capture a particular string from a
japanese website content.

/<ul id="ownerProfile" class="owner">.*?<li>([^<]*?)<\/li>/m

Parsing HTML with Regexp makes certain baby dieties cry.

Use Nokogiri, with an XPath of '/ul[ @id = "ownerProfile" and @class =
"owner" ]'. Then pull out the .text and you are done!
 
S

Srijayanth Sridhar

[Note: parts of this message were removed to make it a legal post.]

That bugle's been blown to death mate.

Jayanth

Arun said:
I'm using the following regexp to capture a particular string from a
japanese website content.

/<ul id="ownerProfile" class="owner">.*?<li>([^<]*?)<\/li>/m

Parsing HTML with Regexp makes certain baby dieties cry.

Use Nokogiri, with an XPath of '/ul[ @id = "ownerProfile" and @class =
"owner" ]'. Then pull out the .text and you are done!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top