Sign in to follow this  
Followers 0
4ggr35510n

Fast and Simple regex question

4 posts in this topic

#1 ·  Posted (edited)

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



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

I think he only wanted the 2's between the table tags (should get two results vice six).

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

PsaltyDS: yup

sahsanu: nope

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  
Followers 0