Jump to content

Recommended Posts

Posted

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.

Posted

$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!

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
  • Recently Browsing   0 members

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