Regexp - Replace Part Of Match
Feb 5, 2006
this will match any instance of a number following a letter/[a-z][0-9]/gmiso thatvar str="abc123 456";alert(str.replace(/[a-z][0-9]/gmi,''));would return "ab23 456".
how would i replace just the number? so as to get back "abc23 456" - or ideally "abc 456" ?
View 1 Replies
ADVERTISEMENT
Sep 22, 2011
I have this string: this is my test <a href="yay.html">yay</a> and want to just match the part before the <a...: this is my test I can't figure out the regular expression for this. I've tried everything I can think of. It seems that it needs to do a non-greedy search on the first < it finds, but nothing works, like: ((.*<)?)
View 2 Replies
View Related
Aug 13, 2010
how can I do a multiple replaces without using regexp? Right now I just have a while that keeps checking if it exist, then if it does, replacing it. Not very efficient.
View 14 Replies
View Related
Jul 1, 2010
Can someone please let me know what this matches - i can work out some but not all code...
View 3 Replies
View Related
Aug 6, 2009
Trying to match a string containing a newline, among other things.
View 4 Replies
View Related
Jul 23, 2005
I am trying to figure out how to set up my reg exp search so that the search
will only match on the exact word.
Here is the current problem code:
Word1 = "RealPlayer.exe"
Word2 = "Player.exe"
RegExp re = Word2;
if (re.Find(Word1))
{
bFound = TRUE;
}
Currently the bFound is set to TRUE since "Player.exe" is found within
"RealPlayer.exe". But I only want bFound to be TRUE is if the entire word
matches.
View 6 Replies
View Related
Sep 25, 2006
I need a regexp function which makes a match when the string contains <img...AND the img tag above dows NOT contain a certain path Here is what I have:
<imgs.*(src).+>
This matches if my string contains "<img .....src.....>" (the dots can be anything, I dont care). However, after the "src" part and before the ....
View 2 Replies
View Related
Jan 11, 2010
why I get an array containing [xml, xml]
Code:
str = 'index.xml'
re = RegExp( /([^s./]+)$/ ) ;
str.match(re) // -> [xml, xml]
I only need xml, not an array, and especially not [xml, xml]
Update: thnx mrhoo, thats clear now!
View 1 Replies
View Related
Apr 11, 2007
Is there a way to get the position of multiple substrings that match a
regexp without using closures? match() returns the substrings
themselves, not the positions, and search() seems to only return the
first position. Here's what seems to work (under Shanti Rao's jsdb.exe
shell) but I get a bit nervous about using closures Code:
View 1 Replies
View Related
Mar 28, 2007
Is there a way in a regexp to *not* match a fixed string value?
Using [^blah] gives matches to anything not containing *any* of letters
b,l,a and h. Whereas I want to match anything that does not containing
the exact string 'blah', i.e. *all* the letters.
Possible?
View 4 Replies
View Related
Jul 13, 2007
I want to replace a string after checking it is valid by passing the values to a function.
The string is '<img width="300" height="300">'
Code:
var text = '<img width=300 height=300>'
text = text.replace(/<img width=(.*?) height=(.*?)>/gi, check_img($1, $2));
The $1 and $2 values are not being passed to the function.
This same method works in PHP by the e Modifier but not in JS.
View 2 Replies
View Related
Nov 6, 2005
How can I replace https://www.some-body.com/cms/ with ../ in this string ?
value highly any help
var str="<br>https://www.some-body.com/cms/file1.txt<br><br>https://www.some-body.com/cms/file2.txt<br><br>";
str=str.replace(
alert(str)
View 3 Replies
View Related
Feb 27, 2010
If I find a line like this: Code: |Note|Dur:16th,Grace|Pos:n-10^|Opts:Stem=Up , I will have to insert the first character after Pos: (n, b, or #) into the Pos: field of a later "Chord" line (will be a list separated by commas). If there is a number (positive or negative) following Pos:, nothing needs to be done.
[Code]....
View 5 Replies
View Related
Jun 10, 2009
is it possible to combine the the following functions with each other in an array for example and if so, would someone be kind enough to show me how. the reasons are 1. to see if it is at all possible and 2. to learn so that I can combine further possibilities in the future. the first script compares user keywords from search mashines and the second replaces certain strings/paterns with others.
[Code]...
View 9 Replies
View Related
Oct 13, 2009
I have a validation regular expression: [?&-#$%():;,._ 0-9a-zA-Z] in a hundreds of pages in edit boxes. Is there anyway I can on-the-fly add two items to this list: (after a page loads)
1) A single quote : '
2) A double quote : "
Sort of like a search and replace for the ENTIRE form (html document).
View 1 Replies
View Related
Oct 6, 2010
I am trying to make a generic function called whenever the window size changes. I want this function to apply to several different images. The idea is that when the window is resized the function will only change the end of the source code by replacing "_small", "_medium", "_large" with the appropriate size depending on the window. The problem is that when I use the code below it makes ALL of the images the same. The variable imageRightIdStr genereates a list of ids of all of the images that I would like this function to affect. ex: #imageRight101,#imageRight201,#imageRight202,#imageRight203,#imageRight301 etc.
Here is the code that I have now. It mostly works except it makes all of my "imageRight_" images the same.
var contentwidth = $('#background').width();
if ((contentwidth) < '1175') {
var logo= $('#pageLogo');
var rightImage = $('.rightImage');
logo.attr('src',logo.attr('src').replace('_large','_small'));
logo.attr('src',logo.attr('src').replace('_medium','_small'));
$(imageRightIdStr).attr('src',$(imageRightIdStr).attr('src').replace('_large','_small'));
$(imageRightIdStr).attr('src',$(imageRightIdStr).attr('src').replace('_medium','_small'));
}else if ((contentwidth) < '1440' && (contentwidth) > '1175') {
var logo= $('#pageLogo');
var rightImage = $('.rightImage');
logo.attr('src',logo.attr('src').replace('_large','_medium'));
logo.attr('src',logo.attr('src').replace('_small','_medium'));
$(imageRightIdStr).attr('src',$(imageRightIdStr).attr('src').replace('_large','_medium'));
$(imageRightIdStr).attr('src',$(imageRightIdStr).attr('src').replace('_small','_medium'));
}
View 3 Replies
View Related
Jan 19, 2010
I would like to know if it is possible to hide a specific aera of a picture with jQuery and cover this zone by another color and text?
View 2 Replies
View Related
Jul 12, 2010
I tried finding a similar situation in the forums, but was unable to discover anything sepcific. I think I may be way off here, and or trying to do something bizarre, but what I am trying to do is change only part of the the url for all of the links on a page. So say I want to change:
href="/something/something/all"
to
href="/something/something/specific"
I think I need to use each() in combination with attr but I am not exactly sure how. This is what I have so far (with no luck):
$('a').each( {
$(this).attr('href').replace('all','specific');
});
I've successfully changed part of a single link based of it's enclosing div id, but if there is more than one link in the div, it replaces the entire href of all the other links in that div to be the same as the first one. So that's why I think I need to use each(). But again, I'm not sure how to do this properly in this case.
View 2 Replies
View Related
Sep 30, 2010
I want to replace a part of a link. See my example below.
The Links :
1)
href="/businessapplications/iop/weschein/Lists/Receipts/EditForm.aspx
?ID=219"
2)
href="/businessapplications/iop/weschein/Lists/Receipts/EditForm.aspx
?ID=220"
[Code].....
View 3 Replies
View Related
Aug 10, 2010
I'm finally diving into regexp by porting a perl script over to js that uses regexp to compress javascript into a bookmarklet capable format.I've successfully worked out 90% of the expressions but am troubled with a few, this one at the moment is odd:I want to remove the first line if it hasjavascript:So I thought str.replace(/^javascripts+:s+/, "") would be ok. I want javascript text, any space, colon, any space and new line. what I'm doing wrong.btw this is the original perl version
$src =~ s{^// ?javascript.+:.+
}{};
View 3 Replies
View Related
May 10, 2010
I am using a Jquery/PHP/MySQL login script which is supposed to display an error or success message when the user enters their username/password and also if the username/pw is successfull go to a secure page. Right now as I have it coded, this isn't working properly. Basically nothing is displayed either way.Also,wasn't sure if I just needed to replace, the ?secure-page part with the file name of the page I want to go to if successful?Here is the code as I have it now.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>[code].....
View 1 Replies
View Related
Jan 19, 2007
I found this in felgall's page. I added script tag
<script type="text/javascript">
var re = /(t)he/g;
var mystring = "Over the moon.";
re.text(mystring);
alert(RegExp.input); // or RegExp.$_
alert(RegExp.leftContext); // or RegExp["$`"]
alert(RegExp.rightContext); // or RegExp["$'"]
alert(RegExp.lastMatch); // or RegExp["$&"]
alert(RegExp.lastParen); // or RegExp["$+"]
alert(re.source);
</script>
I don't see message box. Please tell me what I can do.
View 3 Replies
View Related
Aug 30, 2005
I need to create a dynamically pattern match
for validate a number input, first without
decimals and then with 2 or more decimals.
View 9 Replies
View Related
Jul 23, 2005
i have this function to check date (not mine)
function (s_date) {
// check format
if (!re_dt.test(s_date))
return false;
// check allowed ranges
if (RegExp.$1 > 31 || RegExp.$2 > 12)
return false;
// check number of day in month
var dt_test = new Date(RegExp.$3, Number(RegExp.$2-1), RegExp.$1);
if (dt_test.getMonth() != Number(RegExp.$2-1))
return false;
return true;}
it will check in this format DD-MM-YYYY
is it possible to modify it to be (MM/DD/YYYY OR DD/MM/YYYY) in one function?
View 3 Replies
View Related
Dec 26, 2005
I am weak when it comes to regexp but hoped someone might know in this case.
I am trying to take a url like this :
something.lasso?blah=blah&blah2=blah2&sort=hello&blah3=blah3
And remove the &sort=XXX without hurting the rest of the url. The parameter
to be replaced would be a parameter passed to a function. Here is what I
have so far:
function refresh(item) {
current = document.location.href;
if(current.match(item.name+'='))
//pseudo code here
//current.replace(item.name regexp , '');
return (current + "&" + item.name + "=" + item.value);
This function would be fired like this :
All <input type="radio" name="show" value="all"
onclick="document.location=refresh(this);">
Mine <input type="radio" name="show" value="mine"
onclick="document.location=refresh(this);">
View 13 Replies
View Related
Jul 20, 2005
An important question, probably not treated by many otherwise worthwhile
sources, must be on feature detection of the newer RegExp facilities -
for example, greedy/non-greedy.
The answer may be that it is not possible to do so in a safe manner;
that one can do no better than something like
document.write("Testing non-greedy :- ")
X = /<trialRegExp>/.test(string)
document.write("survived.")
That is, nevertheless, a useful answer; if it is right, it prevents the
naive seeking anything better, and if it is wrong someone will soon say
so.
Where a page requires an advanced RegExp facility, it is best to have a
controlled failure at a well-chosen point.
Putting something in the posted FAQ will provide an opportunity for
adding a reference to the Notes; and, without such a reference, their
value is much reduced.
View 5 Replies
View Related