ugakebet 4 Posted February 4, 2012 Report Share Posted February 4, 2012 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 Quote Link to post Share on other sites
Eddie Waller 158 Posted February 4, 2012 Report Share Posted February 4, 2012 $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") } } 1 Quote Link to post Share on other sites
ugakebet 4 Posted February 8, 2012 Author Report Share Posted February 8, 2012 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 {} } 1 Quote Link to post Share on other sites
Eddie Waller 158 Posted February 8, 2012 Report Share Posted February 8, 2012 $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? Quote Link to post Share on other sites
ugakebet 4 Posted February 10, 2012 Author Report Share Posted February 10, 2012 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{}} Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.