Jump to content

Fast and Simple regex question


Recommended Posts

I'd like to get all "2" numbers from string:

123123<table>123123</table>123123

Is it possible to do it with just one RegExp pattern?

(?:<table>.*?)([0-9]*)(?:</table>)
returns all number between table tags, so I can simple get "2" out of them.

In this situation, my question becomes purely theoretical, but... from 2 hours all what I'm doing is trying to figure it out with just one pattern. I'm rly tired of my own curiosity, so I'm asking for ur help ;]

(?:<table>.*?)([2])(?:.*</table>)
returns only first "2", while
(?:<table>.*)([2])(?:.*?</table>)
only the last one (maybe not visible on example I've chosen), so I'm getting closer to just-one-pattern-solution, but It's still not it :/

Please help :blink:

Edited by 4ggr35510n
Link to comment
Share on other sites

I'd like to get all "2" numbers from string:

123123<table>123123</table>123123

Is it possible to do it with just one RegExp pattern?

Maybe I didn't understand you but...

#include <array.au3>
$string = "123123<table>123123</table>123123"
$result = StringRegExp($string,"2",3)
_ArrayDisplay($result)
MsgBox(0,"","String: " & $string & @CRLF & "Number of 2's: " & UBound($result))
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...