Jump to content
UBot Underground

how to find out if a regex exists?


Recommended Posts

basically what i want is

 

if (find some regex)

{

then blah blah

}

 

im currently using:

 

 

if($find regular expression("city", "[nN]ame|[Ll]ocation|[Cc]ity")) {

then {}

else {}

}

 

but it doesnt return as true, it directly exits the IF statement

Link to post
Share on other sites

$find regular expression returns a list of matches in the text, so in your example it would return a list with 1 item, "city".

 

You could rewrite it as:

 

if($comparison($list total($find regular expression("city", "[nN]ame|[Ll]ocation|[Cc]ity")), ">", 0)) {
   then {
       alert("good")
   }
   else {
       alert("bad")
   }
}

  • Like 1
Link to post
Share on other sites

Hey, eddie, can you tell me whether $find regular expression returns a number back? in your above example, you have written '>0', i assume u want to check it to see whether it returns true. but then do tell me why my code doesnt work (i dont want to check a number i.e. $list_total, i want to see whether it matches the $find regular expression as a phrase/word)

 

Is this wrong??

if($contains($list item(%forum_names_demo1, $list position(%forum_names_demo1)), $find regular expression($list item(%forum_names_demo1, $list position(%forum_names_demo1)), "[nN]ame|[Ll]ocation|[Cc]ity"))) {
then {}
}

  • Like 1
Link to post
Share on other sites

$find regular expression returns a list of the matches it finds. I used $list total to check the length of the list, since if it returns a list with more than 0 elements in it then it matched the expression.

 

I'm not exactly sure if you need anything besides that. If you're still unsure, could you post an example of a site you are trying to work with and what you are trying to do on it?

Link to post
Share on other sites

so eddie tell me what this code will return?

 

 


if($contains("james bond", $find regular expression("james bond, "[nN]ame|[Ll]ocation|[Cc]ity"))) {
then {
nav ("ufo.com")}
else {
nav("google.com")
}

 

 

(there might be some errors in the above code as i have manually typed it in, forget about that for now...)

 

in the above code, will the code navigate to google.com? or will it go to ufo.com (according to me, it should go to google as the regex that i am looking for isnt matched.

But in a similar code that i have, the THEN portoin gets executed as the regex matches a blank line which gets saved in my list)

 

 

how do i do......

 

if (regex exists)

{

then{}

else{}

}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...