File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes javascript string search funcion problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript string search funcion problem" Watch "javascript string search funcion problem" New topic
Author

javascript string search funcion problem

Ravinderjit Singh
Ranch Hand

Joined: Jan 13, 2010
Posts: 68
Hi,

Why search function is unable to find any match?
Here is my code



Result is -1

I know that putting the value inside () is causing this problem, but I am not getting why? Can anyone please shed some light on this?


Thanks.
Keith Wood
Author
Ranch Hand

Joined: Aug 28, 2012
Posts: 38

The parentheses are special characters in a regular expression, which is what your search string defines. To use these, and other special characters, as literal values you must escape them with a double backslash:



Author of the upcoming "Extending jQuery" book from Manning.
Ravinderjit Singh
Ranch Hand

Joined: Jan 13, 2010
Posts: 68
Thanks for your reply.
I resolved this by replacing special characters before search.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javascript string search funcion problem
 
Similar Threads
while-loop
Object expected line 37 char 1 code 0
response unable to receive the parameter sent
String formate
Why does "==" does not return false upon comparison of two String Literals??