Jump to content

Help Regex String Start


Recommended Posts

I have string
number=1
number=2
number=3
selector 
number=4
number=5
number=6

I need regex start string selector  take number 4&5&6 in one pattern unique stringregexp . I don't want regex twice. Please help me, thank you so much !

Link to comment
Share on other sites

I do this. But i want regex once, i don't want use regex twice

#include <Array.au3>
$string = "number=1" & @CRLF & _
"number=2" & @CRLF & _
"number=3" & @CRLF & _
"selector" & @CRLF & _
"number=4" & @CRLF & _
"number=5" & @CRLF & _
"number=6" & @CRLF & _
"number=7"
$regex= StringRegExp(StringRegExp($string,"selector([^\h]+)",1)[0],"(\d+)",3)
_ArrayDisplay($regex)


 

Link to comment
Share on other sites

Here is one
As usual, it works with the provided text but will need to be amended if the requirements are differents in the real life
:idiot:

#Include <Array.au3>

$text = "number=1" & @crlf & _
    "number=2" & @crlf & _
    "number=3" & @crlf & _
    "selector " & @crlf & _
    "number=4" & @crlf & _
    "number=5" & @crlf & _
    "number=6"
;Msgbox(0,"", $text)

$a = StringRegExp($text, '(?s).*selector(*SKIP)(*F)|(\d+)', 3)
_ArrayDisplay($a)

 

Edited by mikell
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...