Click here to Skip to main content
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 OriginalGriff 390
1 Jochen Arndt 165
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 26 Jun 2013
Copyright © CodeProject, 1999-2014
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