Jump to content
Sign in to follow this  
4ggr35510n

Fast and Simple regex question

Recommended Posts

4ggr35510n

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

Share this post


Link to post
Share on other sites
sahsanu

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))

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.