Jump to content

StringRegExp() 4th parameter


phew
 Share

Recommended Posts

hi!

i have created following regexp:

$parameter = StringRegExp($cmdl[1], '(.*?)' & Chr(34) & '(.*)' & Chr(34) & '(.*?) (-[ns]{0,1})', 1)

so i get an array with 4 values, $parameter[0], $parameter[1], $parameter[2], $parameter[3], ie:

$cmdl[1] = "hellothisis justatest xyz -n"

so:
$parameter[0] = hellothisis
$parameter[1] = justatest
$parameter[2] = xyz
$parameter[3] = -n

but now i want the StringRegExp() also match when the 4th parameter, the -n OR -s is not in the string, so when the 4th parameter is optional:

$cmdl[1] = "hellothisis justatest xyz"

so:
$parameter[0] = hellothisis
$parameter[1] = justatest
$parameter[2] = xyz
$parameter[3] =                <------ empty, " "

how do i do that? the regexp i use (the one above) does only match when -n or -s is specified, but not if i have no -s or -n.

help please!

Link to comment
Share on other sites

If none of the commands contain spaces, you could just do:

StringSplit($cmdl[1], " ")

this won't work either, because my second parameter can have spaces in it and so this would be split, too

EDIT:

to make it more clear:

i am looking for a way to make a group in a regexp, ie. (.*?) optional. so if there is a group like (.*?) in the string the regexp matches and if there isn't the regexp matches, too. in other programming languages it's often '\' used for that, like \(.*?\) to make the whole group "optional". there must be smtn similiar in au3, too, i'm sure

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