Need Help with regular expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lucky

    Need Help with regular expression

    hi guys,


    i'm looking for a RegEx which can find these type of string from the
    bunch of html lines. if any one can help me here, would be appriciated.



    <a
    href="/url?sa=p&pref=i g&pval=2&q=http ://www.google.co.i n/ig%3Fhl%3Den"
    onmousedown="re turn rwt(this,'pro', 'hppphou:def',' ')">Personalize d
    Home</a>
    <a
    href="https://www.google.com/accounts/Login?continue= http://www.google.co.i ...">Sign

    in</a>
    <a id=1a class=q href="/imghp?hl=en&tab =wi" onClick="return
    qs(this);">Imag es</a>
    <a id=2a class=q href="http://groups.google.c o.in/grphp?hl=en&tab =wg"
    onClick="return qs(this);">Grou ps</a>
    <a id=4a class=q href="http://news.google.co. in/nwshp?hl=en&tab =wn"
    onClick="return qs(this);">News </a>
    <a href="/intl/en/options/" class=q>more&nb sp;&raquo;</a>
    <a href=/advanced_search ?hl=en>Advanced Search</a>
    <a href=/preferences?hl= en>Preferences</a>
    <a href=/language_tools? hl=en>Language Tools</a>
    <a href="http://www.google.co.i n/hi">Hindi</a>
    <a href="http://www.google.co.i n/bn">Bengali</a>
    <a href="http://www.google.co.i n/te">Telugu</a>
    <a href="http://www.google.co.i n/mr">Marathi</a>
    <a href="http://www.google.co.i n/ta">Tamil</a>
    <a href="/ads/">Advertising&n bsp;Programs</a>
    <a href=/intl/en/about.html>Abou t Google</a>
    <a href=/jobs/positions-in.html onmousedown="re turn
    rwt(this,'pro', 'hppwebjob:en_i n','')">We're Hiring</a>
    <a href=http://www.google.com/ncr>Go to Google.com</a>


    guys, please do help me. i'm in big trouble

  • Spidey

    #2
    Re: Need Help with regular expression

    Could you be a little more specific? The example you have cited is not
    clear enough. Regular expressions are used to match complex patterns
    from a string
    e.g. if you wanted to find all instances of "Windows 95" and "Windows
    98" but not "Windows 2000"

    If you want to find all instances of a specifc string, you are better
    off using the string.IndexOf method.

    Regards,
    Sarin.

    Lucky wrote:[color=blue]
    > hi guys,
    >
    >
    > i'm looking for a RegEx which can find these type of string from the
    > bunch of html lines. if any one can help me here, would be appriciated.
    >
    >
    >
    > <a
    > href="/url?sa=p&pref=i g&pval=2&q=http ://www.google.co.i n/ig%3Fhl%3Den"
    > onmousedown="re turn rwt(this,'pro', 'hppphou:def',' ')">Personalize d
    > Home</a>
    > <a
    > href="https://www.google.com/accounts/Login?continue= http://www.google.co.i ...">Sign
    >
    > in</a>
    > <a id=1a class=q href="/imghp?hl=en&tab =wi" onClick="return
    > qs(this);">Imag es</a>
    > <a id=2a class=q href="http://groups.google.c o.in/grphp?hl=en&tab =wg"
    > onClick="return qs(this);">Grou ps</a>
    > <a id=4a class=q href="http://news.google.co. in/nwshp?hl=en&tab =wn"
    > onClick="return qs(this);">News </a>
    > <a href="/intl/en/options/" class=q>more&nb sp;&raquo;</a>
    > <a href=/advanced_search ?hl=en>Advanced Search</a>
    > <a href=/preferences?hl= en>Preferences</a>
    > <a href=/language_tools? hl=en>Language Tools</a>
    > <a href="http://www.google.co.i n/hi">Hindi</a>
    > <a href="http://www.google.co.i n/bn">Bengali</a>
    > <a href="http://www.google.co.i n/te">Telugu</a>
    > <a href="http://www.google.co.i n/mr">Marathi</a>
    > <a href="http://www.google.co.i n/ta">Tamil</a>
    > <a href="/ads/">Advertising&n bsp;Programs</a>
    > <a href=/intl/en/about.html>Abou t Google</a>
    > <a href=/jobs/positions-in.html onmousedown="re turn
    > rwt(this,'pro', 'hppwebjob:en_i n','')">We're Hiring</a>
    > <a href=http://www.google.com/ncr>Go to Google.com</a>
    >
    >
    > guys, please do help me. i'm in big trouble[/color]

    Comment

    • Lucky

      #3
      Re: Need Help with regular expression

      okey dude,
      ultimately i made one regEx by myself. here it is for all those who
      are in need for the same

      <a [a-zA-Z0-9 ="'.:;?]*href=*[a-zA-Z0-9 ="'.:;>?]*[^>]*>([a-zA-Z0-9
      ="'.:;>?]*[^<]*<)\s*/a\s*>


      copy all the links from my last post into one string and run this
      expression. it will show you the o/p that i wanted.

      Comment

      Working...