diveboy Posted January 22, 2010 Posted January 22, 2010 hi, wanting to StringRegExp the following string "2 NOTE Digger - Death Index. Victoria 1921-1985" as an example. Want to get an array back splitting the first two white spaces and the rest as a string, so [0]='2' [1]='NOTE' [3]='Digger - Death Index. Victoria 1921-1985" as an example.' I'm using StringRegExp('2 NOTE Digger - Death Index. Victoria 1921-1985','\S+', 3 ) which returns each word between white spaces, I only need the first two white spaces split [0]|2 [1]|NOTE [2]|Digger [3]|- [4]|Death [5]|Index. [6]|Victoria [7]|1921-1985 can someone tell me how to get regexp to act on the first two white spaces ? Thanks Michael.
zorphnog Posted January 22, 2010 Posted January 22, 2010 $sSomething = "2 NOTE Digger - Death Index. Victoria 1921-1985" $aResult = StringRegExp($sSomething, "(?U)(.+)\s(.+)\s(.*)\Z", 3)
diveboy Posted January 22, 2010 Author Posted January 22, 2010 $sSomething = "2 NOTE Digger - Death Index. Victoria 1921-1985" $aResult = StringRegExp($sSomething, "(?U)(.+)\s(.+)\s(.*)\Z", 3) Thanks zorphnog, works a treat. if your ever in Melbourne, look me up, first beer is on me!
Mison Posted January 25, 2010 Posted January 25, 2010 Without regex: #include <array.au3> ; for _ArrayDisplay $string = "2 NOTE Digger - Death Index. Victoria 1921-1985" $array = StringSplit(StringReplace($string," ","++delim101++",2),"++delim101++",3) _ArrayDisplay($array) Hi ;)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now