I'm trying to to verify if a string contain this simbol \.
if (this.inputCity.includes('\')){
// do something,,,
}
The problem is that backslash? is an escape? character... So how can I check if string contain \ ?
Thanks!
I'm trying to to verify if a string contain this simbol \.
if (this.inputCity.includes('\')){
// do something,,,
}
The problem is that backslash? is an escape? character... So how can I check if string contain \ ?
Thanks!
You can escape the escape character by just adding another one:
if (this.inputCity.includes('\\')){
// do something,,,
}
Because it's an escape character, you have to escape it with another backslash. :)
if (this.inputCity.includes('\\')){
// do something,,,
}
I think you want to use the AND operator:
if(this.inputCity.includes('\\') && this.inputCity.includes('/') {
// This will run if inputCity includes \ AND (hence the operator name) /
}