Sign in to follow this  
Followers 0
SagePourpre

[...] Isolate variables...

2 posts in this topic

Hi !

I would like to take off this expression all variables

CODE
$expression = 'MouseClick("left",$x,$Y,$click)

I have thought of something like this.

CODE
$expression = stringsplit($expression,"$")

it gives an array like that

1 = MouseClick("left",

2 = x,

3 = Y,

4 = $click)

I want now that each string following array[2] to array[0] to be analysed and if symbols "+" "-" "=" ")" or " " to cut

this string down again.

Finally it would give me something like this

2 = x

3 = y

4 = click

The names of my variables

To recapitulate, here's the code I already made

CODE
$expression = 'MouseClick("left",$x,$Y,$click)

$expression = stringsplit($expression,"$")

Now I want to "read the string" stop at those symbols "+" "-" "=" ")" or " " and to return the result of what is between my stringsplit "$" and symbols,

also known as ... variables names found in $expression

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you just want variables, you should run a regular expression for pseudo expression "starts with $, contains letters numbers underscore, ends with non letter number underscore". I don't know enough about regular expressions but I know this is doable.

Edited by Richard Robertson

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