Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

jquery - how to replace the text with desired text in a para -


i have following code.. in trying find particular text , replace desired one.. working fine if string in same case.. if give capitals (like.. the) not giving out put.. solution this.. can use regular expressions in one..? please me

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html>  <head>   <title> new document </title> <script type="text/javascript" src="jquery-1.4.2.min.js"></script> <script> $(document).ready(function(){ $('#replace').click(function(){ var oldstr=$('#inputstring').val(); var newstr=$('#newstring').val(); var para=$('#para').html();  var x=para.replace(oldstr,newstr); $('#para').empty().html(x);  }) }) </script>  </head>  <body> enter string here:<input type="text" id="inputstring"><br> enter new string here:<input type="text" id="newstring"><br> <input type="button" id="replace" value="replace"><br>  <p id="para">this new paragraph written test how replace string desired string</p>  </body> </html> 

you need use ignorecase flag regular expression.

para.replace(new regexp(oldstr, 'i'), newstr 

docs: https://developer.mozilla.org/en/javascript/guide/regular_expressions


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -