Hi this should be an easy one and I couldn't find it anywhere.
How do I replace just the last character of a string with a char from an array?
str1 = str1.replace(?????, ...
|
i have a string which contains square boxes(i found it's ascii code as alt+207)...how i can replace this with ' '(a single space).
Thanks in advance.
|
r = r.replace(/<TR><TD><\/TD><\/TR>/gi, rider_html);
...does not work in IE but works in all other browsers.
Any ideas or alternatives?
|
I am trying to do a modify a text which contain some special tags. I belive it should be possible by a single regular expression, but am stuck...
What I want ... |
So, I have a function which has two params: string and match index to replace and i need to replace only match with that index. How can i do that?
Example:
replace('a_a_a_a_a', 1)
Result:
a__a_a_a
... |
regexp:
var s = document.getElementById("username").value; if s == "\ \ \ \"; var result = s.replace(/\/g,"") will be wrong? why that firebug error ?
hope to the result is ... |
How do you use the matched variables in the pattern in the replacement string?
var regexp = new RegExp('needle', 'ig');
str.replace(regexp, '<span class="marked">//1</span>')
|
|
If I have the following string:
var str = "Test.aspx?ID=11&clicked=false+5+3";
str = str.replace(????????, 'true');
How can I replace the substring "false+5+3" with "true" using REGEX?
Thanks in advance!!!
|
I have the string: \rnosapmdwq\salesforce\R3Q\OutputFiles\Archive
I'm getting a unrecognized escape sequence when I try to send this to a .NET web service.
I'm trying to replace all of the "\" with "|" to ... |
I'm trying to parse and amend some html (as a string) using javascript and in this html, there are references (like img src or css backgrounds) to filenames which contain full ... |
I have some JavaScript which replaces smiley symbols with their corresponding images in my blog.
So symbols like :) or :( are replaced by proper <img> tags.
Currently there are around ... |
I want to replace a simple text like:
1 day ago to Hace 1 dia
I have tried the following code, but it does not work:
var texto = "1 day ago";
texto = texto.replace('/\d+(?=day ...
|
I would like to replace a string.
I have tried this, which I thought would work, but it doesn't
string = "/*"
string.replace(/\/(?=\*)/g,"replaced")
I tried escaping the asterisk and leaving it alone but both didn't ... |
var isbn = '978-0393317558';
alert(isbn.replace(/^[^0-9]+/, '')); //this gives the same value
Why isn't that dash being replaced?
|
try{
var hdnPassenger = $("#ctl00_ContentPlaceHolder1_hdnPassenger").val();
var newTr = $("#hdnCtl").html();
newTr = newTr.replace(/_ID/g, hdnPassenger);
}
catch(ex){
alert(ex);
}
Above code is working fine in the ... |
Are there differences between these two?
replace(/[^a-z0-9]/gi, '');
replace(/[^a-zA-Z0-9]/g, '');
Also, are there any significant differences in time using one or another?
edit: about the performance, I did some testing http://jsperf.com/myregexp-test
|
I need this:
Input
<div>some text [img]path_to_image.jpg[\img]</div>
<div>some more text</div>
<div> and some more and more text [img]path_to_image2.jpg[\img]</div>
Output
<div>some text <img src="path_to_image.jpg"></div>
<div>some more text</div>
<div>and some more and more text <img src="path_to_image2.jpg"></div>
This is my try and also ... |
I'm trying to "remove" (just replace it with "") the following String:
<script type="text/javascript">
document.createElement("img").src="http://www.google.com"
</script>
From the following String:
<SCRIPT LANGUAGE=JavaScript>
var PAswf = "_ADPATH_[%SWF File%]";
var advurl = "_ADCLICK_";
var PAadvurl = escape(advurl);
var PAwidth = "[%Width%]";
var PAheight ...
|
I have a string like,
(Range:(>"A" OR Range:(>"B" OR Range:(>"AB")
I need to convert it like,
(Range:(>"A") OR Range:(>"B") OR Range:(>"AB"))
please help me out how to identify it with regex.
Thanks in advance
|
string.replace(/""\n/g,"\"\""+ "\n")
I am trying to parse a string and for using JSON parser. I need to replace the occurrence ""\n (quote, quote, newline) with \\"\\"\n (slash, quote, slash, quote, newline).
I tried ... |
Hey guys this is an easy one. I already am doing a replace for the commas in an textbox. How would I replace if there is an "$" and ... |
This code will replace the comma's no problem, but will leave the $ for some reason... Is it set up wrong? Trying to replace the $ also.
function doValidate() {
...
|
why this regular expression replacement doesnt work?
var url = 'http://myweb.com/page/1/id/2';
newUrl = url.replace('/page\/[0-9]+/', 'page/2'); //it must become http://myweb.com/page/2/id/2
|
wish to escape all occurrences of "." and ":" within square brackets
[ab:1.2:ef]='12.3' => [ab\:1\.2\:ef]='12.3'
tried various permutations on replace, eg,
str.replace( /(\[.*)(\.|:)(.*\])/g, '\1\\\2\3' );
but no joy.
Both answers correct and more.
The first, a ... |
I'm working on regex (regexes, actually) that will satisfy my needs. :)
I need to replace given string (named title) and return slug:
- Replace one white-space with one underscore in places where are ...
|
I know that I can create a javascript replace like this:
str = str.replace(/mytarget/g, 'some value');
that will replace all the occurances of the literal mytarget.
However, I have a big array of words/phrases ... |
I would very much appreciate some assistance from the community on replacing a string at xth position intervals, using javascript regex. For example, if the string length is 161 and ... |
When I want to replace some parts of a string, should I call replace directly like this?
var r1 = /"\+((:?[\w\.]+)(:?(:?\()(:?.*?)(:?\))|$){0,1})\+"/g;
arg = arg.replace(r1, function(outer, inner){
return eval(inner);
});
Or test for ... |
Hello there ,
var s = "width:20px;height:25px;color:red;font-family:myfontfamily";
i have a string like this,now how can i change the values of width,height etc using javascript.there may be a \n after or before the ... |
I have a program that allows a user to type JavaScript in a textbox, and it executes in an HTML viewer or iframe. There is a drop down with options such ... |
I am checking a collection and replacing all
<Localisation container="test">To translate</Localisation>
tags with text.
The next codes does what I want:
var localisationRegex = new RegExp("(?:<|<)(?:LocalisationKey|locale).+?(?:container|cont)=[\\\\]?(?:['\"]|("))(.+?)[\\\\]?(?:['\"]|(")).*?(?:>|>)(.*?)(?:<|<)/(?:LocalisationKey|locale)(?:>|>)", "ig");
...
|
I have the following string:
Are you sure you want to delete "%lg_name%" group?
And in Javascript I have the variable lg_name. How can I replace lg_name string to lg_name varible? This regex ... |
The pattern in this code does not replace the parenthesis. I've also tried "/(|)/g".
var re = "/[^a-z]/g",
txt = navsel.options[i].text.split(" ")[0], // here I get the text from a ...
|
last_tag="abcde x";
last_tag = last_tag.replace(/[\s]+x$/, '');
this is my problem: i have to remove an "x" at the end of my string. This piece of code is used in a plugin ... |
I'm trying to match usernames within a string like:
"user: hi, has anyone seen user today user"
The cases to match:
- substring is the first word trailing a space, in the middle surrounded by ...
|
I'm prototyping some text processing to prep research data for coding, and I've got a javascript replace statement the bombs in jsFiddle and I cannot figure out why:
mE[1] ...
|
I'm attempting to replace url's in a string by calling a function that shortens the url's and then replaces the text. The shortening logic works perfectly, and I end up with ... |
actually I want to replace a string except if it comes in a round bracket.
For example:
JAVA is a nice language. (JAVA) has lots of features. JAVA is portable. (JAVA) ...
|
I have a string like this: ----------- 243f,33f----
Now I want to remove all the - chars except the first -, the , and the numbers. ... |
Need a regular expression. If I want to replace "abcdf" with "PPP" in
XabcdfX is xxxxxxx. <MabcdfM> has xxxxx. abcdf is xxxxxxx. <FabcdfF> zxabcdf abcdf.
then the expected output
XPPPX is ...
|
I have this string:
var s = '<span style="font-size:13px">20<div class="lblTitle"></div><span>';
I'd like to replace the 20 to 40, I tried:
a.replace(/>(\d*)</, 40)
But it will ... |
I have a string, where I need to parse it as a float, but first I need to replace it, if it is not a number (an integer or a float), ... |
|
|
|
|
function pageJump( obj ) { var name = obj.name; var val = obj.options[obj.selectedIndex].value; var pattern = new RegExp(name+'=[0-9]+'); var tmp = location.href.split('?'); var href = tmp[0]; var query = tmp[1]; if ( query && query.match(pattern) ) { var replaceStr = name+'='+val; query.replace(pattern,replaceStr); alert(query+' : '+name+'='+val+' : '+pattern+' : '+replaceStr); } else if ( query && query != '' && query !== ... |
|
hi, i have a problem with a call to the javascript string.replace() function. here's my code: function parseCodes_parseBold(s) { var re = /\[b\](.*)\[\/b\]/ig; return s.replace(re, "$1"); } all it does is convert a bbcode into html. so for example: [ b]bold text[/b] (no space obviously) would produce bold text (bold of course) my problem is that the regex matches the furthest ... |
|
|
var subject = 'bargain'; var foo = 'bar'; // works : use a variable and the pattern is the value of the variable var pattern = new RegExp(foo,"g"); str1 = subject.replace(pattern,''); alert(str1); // output : 'gain' // does not work : it looks for the literal string 'foo' str2 = subject.replace(/foo/g,''); alert(str2); // output : 'bargain' |
|
Hi All, I have this function that I'm using to preview a forum post. I'm trying to get it to remove the Break tags WITHIN the code blocks and not BETWEEN the code blocks and cant seem to find the right RegExp expression to do it. As you can see I'm converting the code blocks into a textarea input field much ... |
|