Jump to content
UBot Underground

Recommended Posts

Is it possible to make contains function case insensitive? I got the following code:

set(#var,%nte,"Global")
if($contains(#var,"Point")) {
then {
alert("contains!")
}
else {
alert("Does not contain")
}
}

So I have the list "%nte" and set it as the variable #var. The list contains the word Point. I would like to alert "contains! even if I search for the word "point" with lowercase p in the variable or any other lower and uppercase mix like "PoInT". Now it only shows "contains!" alert if I search for Point with the uppercase P.

Edited by chinotto
Link to post
Share on other sites

set(#MyVar,"point","Global")
if($comparison($find regular expression(#MyVar,"(?i)Point"),"!= Does not equal","")) {
    then {
        alert("contains!")
    }
    else {
        alert("Does not contain")
    }
}
set(#MyVar,"Point","Global")
if($comparison($find regular expression(#MyVar,"(?i)Point"),"!= Does not equal","")) {
    then {
        alert("contains!")
    }
    else {
        alert("Does not contain")
    }
}
set(#MyVar,"We\'ve done everything we point 123","Global")
if($comparison($find regular expression(#MyVar,"(?i)Point"),"!= Does not equal","")) {
    then {
        alert("contains!")
    }
    else {
        alert("Does not contain")
    }
}
  • Like 2
Link to post
Share on other sites

Perfect!! Thank you so much Pash!! This is exactly what I was looking for:

set(#MyVar,"We\'ve done everything we point 123","Global")
if($comparison($find regular expression(#MyVar,"(?i)Point"),"!= Does not equal","")) {
    then {
        alert("contains!")
    }
    else {
        alert("Does not contain")
    }
}

Thanks again!

Edited by chinotto
  • Like 1
Link to post
Share on other sites

Nice Pash!

 

 

here is the more versatile function for this, this way you can use for any word.

 

alert($is in text("We\'ve done everything we point 123", "Point"))
alert($is in text("We\'ve done everything we Point 123", "bob"))
define $is in text(#TEXT TO CHECK, #TEXT TO SEARCH) {
    if($comparison($find regular expression(#TEXT TO CHECK,"(?i){#TEXT TO SEARCH}"),"!= Does not equal",$nothing)) {
        then {
            return("true")
        }
        else {
            return("false")
        }
    }
}

 

 

CD

  • Like 1
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...