Regexp simple question


#1

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

/

    .?
  • ([^<]
  • ?)</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


#2

In words, describe what just the regex part does.


#3

7stud – wrote:

In words, describe what just the regex part does.

I mean the part between the

  • tags.

  • #4

    Your boss doesn’t like gsub?

    Try

    /

      .?
    • ([^</]
    • ?)</li>/m

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

      Jayanth


    #5

    That bugle’s been blown to death mate.

    Jayanth


    #6

    Arun K. wrote:

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

    /

      .?
    • ([^<]
    • ?)</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!