Click here to Skip to main content
11,414,561 members (68,571 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi,

i have a s string :

"
$(document).ready(function(){
 
$("#btn1").submit(function(e1){
   if(e1.keyCode==13){         
       e1.preventDefault();
   }
});
});
"

i want to find a specific content :

"
$("#btn1").submit(function(e1){
   if(e1.keyCode==13){
       e1.preventDefault();
   }
})
"

Any suggestion.
please help!
Posted 26-Jun-13 0:49am
Edited 26-Jun-13 0:51am
v2
Comments
ThePhantomUpvoter at 26-Jun-13 5:59am
   
http://msdn.microsoft.com/en-us/library/dy85x1sa%28v=vs.100%29.aspx

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Both JS and C# strings have an IndexOf method. This returns the character position if the string is matched. If it's not matched it returns -1.

If you want to check in javascript its

stringValue.indexOf('MyString');

If you need to check none case sensitive

stringValue.toLowerCase().indexOf('mystring');

If you want to check with c#

stringValue.IndexOf("MyString");

Again, not case sensitive

stringValue.toLower().IndexOf("mystring");
  Permalink  
Comments
rohit24c at 26-Jun-13 6:03am
   
i want to find the entire piece of string
"{

$("#btn1").submit(function(e1){
if(e1.keyCode==13){
e1.preventDefault();
}
});
});"

from the main string
Stephen Hewison at 26-Jun-13 6:07am
   
And I've just shown you how to do that.
Khan JI at 26-Jun-13 7:47am
   
Dude index off basically provide the exact location(index) of the parameter in the string.. i.e if you have a string like....

rohit_24c and if you wana get index of t than you can use indexof("t") which in result will provide you 5 than by using that index in .substring() method you can get the desired string..

For reference see the links below.

http://www.w3schools.com/jsref/jsref_substring.asp

http://www.w3schools.com/jsref/jsref_indexof.asp

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,160
1 OriginalGriff 7,487
2 Maciej Los 3,710
3 Abhinav S 3,298
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web01 | 2.8.150427.4 | Last Updated 26 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100