Tagged Questions
1
vote
3answers
37 views
Having issues with a replace function in Javascript
Okay, so I have some variables in javascript...
var link = 'http://8wayrun.com/streams/multi?type=3&pos1=1.teamsp00ky.video&pos2=1.teamsp00ky.chat&pos3=1.nycfurby.chat';
var position = 2;
...
2
votes
1answer
52 views
Why isn't my regex matching the entire document?
I'm trying to build a small Javascript application which loads a third party site, finds a given word and highlights the closest context of the document using the Jquery extension Highlight (with a ...
0
votes
3answers
24 views
Encoding URL partially in Javascript and PHP (url tweak)
that might be something strange when I say that I want to encode a URL partially, But I am caught in this situation and it seems that I got no other solution...
here is my code snippet
$url = ...
0
votes
3answers
28 views
RegEx to match only numbers incorrectly matching
I'm trying to use a regular expression in JavaScript to match a number or a number containing a decimal. The regular expression looks like [0-9]+ | [0-9]* \. [0-9]+.
However, for some reason this ...
1
vote
2answers
25 views
How to replace as substring of a word using javascript regexp
I am trying to replace all occurrences of a regexp pattern with a new word. Currently I can only replace the coinsurance if it is an individual word that separated by space " ", but I would like to ...
0
votes
3answers
65 views
Space between two words
I am looking for a regular expression to check that there are at least two words in my input field.
I tried this:
var spaceReg = /^\w+\s\w+$/
It works fine but if I have three or more words, not ...
-2
votes
1answer
37 views
whitespace between quote and word character [closed]
I have the following string: <Keyword WordId="3260"IdId="125039"AnotherId="3098"> I need to turn it to <Keyword WordId="3260" IdId="125039" AnotherId="3098"> using js. Basically, I need to ...
1
vote
1answer
49 views
Remove leading zeros with regex but keep minus-sign at JavaScript
Does someone have an idea how to remove leading zeros with regex but keen minus sign?
It so easy to do that for positive values
.replace(/^0+/,'')
but I absolutely have no idea how to do ...
0
votes
2answers
36 views
Find and alter links with js in a text
I have a text that must be send as an email. But to give the mail its layout we need to add some style.
What we must do is the following:
1 find in a text one or more links with this format
<a ...
1
vote
1answer
39 views
How to extract array of numbers from string in javascript
Using javascript, I need to extract the numbers from this string:
[stuff ids="7,80"]
and the string can have anywhere from one to five sets of numbers, separated by commas (with each set having 1 ...
0
votes
3answers
32 views
What would be the JavaScript pattern to match anything except a given string?
I need to make sure a given string is not "Select a value". That's it, anything else should match the pattern, except this exact string.
I've been looking around and trying many combinations on ...
3
votes
2answers
45 views
Javascript Regex rule is breaking asp.net minification
I have this function, it works fine in all browsers:
cleanKey = function( key ){
return key.replace( ...
0
votes
2answers
40 views
Split a string of html into array of string, split by top level tag
Say I have
var string =
"<h1>Header</h1>
<p>this is a small paragraph</p>
<ul>
<li>list element 1.</li>
<li>list element 2.</li>
...
6
votes
2answers
41 views
Regex test function do not return the same depending quotes
I have a weird case with a regular expression in javascript:
var re = /[^\s]+(?:\s+|$)/g;
re.test('foo'); // return true
re.test("foo"); // return false
Is a regular expression type sensitive? My ...
-3
votes
1answer
58 views
What does this Regex want to do in JavaScript? [closed]
What does this regex do in JavaScript?
function fn (str) {
str.replace(/((^|%>)[^\t]*)/g, "$1\r");
}
0
votes
2answers
48 views
Replacing XML attribute values using regex
I have an svg stored in a string. A part of it looks like:
var str = '<svg version="1.1" width="1400px">';
I'm looking for a solution that will replace the value of any given property. Right ...
0
votes
1answer
39 views
how to validate not to allow Chinese characters
One of my SQL like statement is breaking when user enters Chinese characters. I did some research and couldn't find any.
Is there any code available like a plugin or javascript function to validate ...
3
votes
4answers
45 views
Javascript regex get the number part from a specific word
Say that we have an element with these classes: "floatLeft item4".
If I want to save the number "4" to a variable from "item4" how would i do that?
I think I would use this pattern "/item(\d+)/" but ...
0
votes
1answer
36 views
Javascript number regex test failing - can't figure out why
Here's a jsFiddle: jsFiddle
Relevant code:
var number = /\d+(.\d+)?/g;
$('body').append(number.test(2.5) + "<br>");
$('body').append(number.test(20) + "<br>");
...
-1
votes
2answers
78 views
Regex for Detecting the Text Inside of <a></a> Tags
I have this regex that finds the text between HTML anchor tags in my string of text. The text is comparable to a Tweet, so a sample string would be:
http://google.com is great, but ...
-6
votes
3answers
52 views
Find and parse url in dom-element value using RegExp and jQuery [closed]
Here is part of my html code:
<span id="ctl08"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ...
1
vote
2answers
39 views
regex for matching finite-depth nested strings — slow, crashy behavior
I was writing some regexes in my text editor (Sublime) today in an attempt to quickly find specific segments of source code, and it required getting a little creative because sometimes the function ...
1
vote
2answers
44 views
How do I replace non-numeric characters in string while excluding periods?
So I have this-
lr_min = $('#lr_min').val().replace(/\D/g,'');
It gets rid of all the nonnumeric characters in the string. How do I exclude periods (.) from this replace?
2
votes
3answers
56 views
regex remove all periods that are not following by digits
I have str.replace(/.(?![0-9])/g, '').
But it removes everything except the period and the digit after the period.
For example "3.14" becomes ".1"
What I want is:
"3.14" -> "3.14"
"hello.world" ...
0
votes
1answer
20 views
Replacing\Changing Alpha in RGBA JavaScript
I'm trying to change the Alpha in RGBA, from some reason replace acts strange and instead of resulting with: "rgba(30, 43, 2, A)" i end up with: "A".
Here is the code:
var color="rgba(30, 43, 2, ...
-1
votes
4answers
56 views
How to replace a substring with open parentheses (
I am a Regex newbie and trying to implement Regex to replace a matching pattern in a string only when it has a ( - open parentheses using Javascript. for example if I have a string
IN(INTERM_LEVEL_IN ...
1
vote
2answers
58 views
Regex not working for specific condition
i am trying only to allow numerals and special chars like '.' and ',' to be allowed in my text string. for that i have tried following code
var pattern = /[A-Za-z]/g;
var ...
0
votes
4answers
54 views
Replace backslash with '-' in a string - strange behaviour
I have seen all the questions asked previously but it didn't help me out . I have a string that contains backslash and i want to replace the backslashes with '-'
var s="adbc\sjhf\fkjfh\af";
s = ...
0
votes
2answers
111 views
Regex password validation using JavaScript
I need to validate (and confirm) a new password on a site. There are criteria I need to test for, and I'm looking for the best method to do so, using jQuery.
The criteria are:
Must have a minimum ...
0
votes
2answers
56 views
Allowing negative and positive decimals in javascript.replace
I am using this to filter out everything that isn't a number (including decimals)
On keydown I am doing this:
function validateNudgerInput(ele){
ele.val(ele.val().replace(/[^0-9\.]/g,''));
...
1
vote
2answers
62 views
Need to identify the non-matching character in regex
We use a regex to test for 'illegal' characters when a user provides a 'Version Name' before we save their content. The accepted characters are: A-Z, 0-9 and blank space. We test this using the ...
0
votes
2answers
22 views
Tricky number regexp with fractional and negative condition
I'm looking for regexp to validate numbers includes fractional and negative condition.
As for me tricky part of this regexp is - if number starts from 0, it must be fractional.
so
true:
0.12
...
0
votes
2answers
59 views
Replace a sequence of Numbers using regex
I am trying to replace a sequence fragment "123", in a number sequence such as 12312345435 and remove the repetitive sequence of 123 from the start. So after the replace the new number sequence would ...
0
votes
2answers
53 views
javascript string replace with RegExp
I got a problem with javascript RegExp. I want to replace the a.href with textbox value when I click on the button.But, I don't want to replace the whole string just want to find and replace those are ...
3
votes
3answers
56 views
how to linkify unicode numbers in javascript using regex
How can I change the regex below to also select the unicode numbers? Currently only ASCII numbers are selected.
function numberfy(text) {
var urlRegex = /[+0-9]+(?:\.[0-9]*)?[0-9]{5,}/g;
...
0
votes
2answers
36 views
Regex to return start time (#t=) from YouTube URL [duplicate]
I'm looking for a way that I can get a URL like any of these:
http://www.youtube.com/watch?v=Nlwa0ZWrO8g#t=1m30s?someweirdthing
http://www.youtube.com/watch?v=Nlwa0ZWrO8g#t=90s&anotherweirdthing
...
1
vote
2answers
39 views
Form validation regex and DOM: What would be the best way to implement regex in a form validation
Form validation regex and DOM:
What would be the best way to implement regex in a form validation?
Im currently doing this, but when I validate it's not matching the values:
if(this.value.length ...
1
vote
4answers
57 views
Regex to check if whitespace present?
Seems pretty simple, but cannot figure out why this javascript code isn't working returning false, when expecting true) - I'm guessing it has got to do something with the escape characters? Could ...
-2
votes
1answer
30 views
Replacing every third comma
This works to replace every other comma. What do I have to do to replace every third comma?
resultContent = resultContent.replace(/(,[^,]*),/g, '$1|');
0
votes
2answers
30 views
Javascript Regex for Removing http:// and https:// from text
I found this JS script here on SO that seems like it will work great for detecting both regular links and Twitter #hashtags and @usernames:
function processTweetLinks(text) {
text = ...
3
votes
2answers
59 views
Regex to count the number of capturing groups in a regex
I need a regex that examines arbitrary regex (as a string), returning the number of capturing groups. So far I have...
arbitrary_regex.toString().match(/\((|[^?].*?)\)/g).length
Which works for ...
0
votes
2answers
49 views
MQTT topics and uniqueness issue
I'm experimenting a bit with MQTT and I've run into a bit of weirdness. It could be due to my specific setup but I thought I'd ask away anyway.
I'm using Node.JS and mqttjs as a broker. I'm also ...
1
vote
1answer
49 views
Regular expression crashing Chrome when used as RegExp()
The regex in question is:
/\[quote\]((?:[^](?!\[quote\]))*?)\[\/quote\]/gi
The string I'm applying it to is
[quote]Level 10
[quote]Level 9
[quote]Level 8
[quote]Level 7
[quote]Level 6
...
1
vote
1answer
42 views
Match Phone Numbers Regardless of Formatting
I've written a query for Mongo to search for a phone number. The gotcha is the phone entry is a String rather than a Number. At first I thought it was working fine, however now I realize that if the ...
-2
votes
3answers
29 views
How can I get the last part of a songkick URL using regex?
I need to get the last part after the slash from this URL or even just the number using regex:
http://www.songkick.com/artists/2884896-netsky
Does anyone know how I can go about doing this?
Many ...
1
vote
5answers
32 views
Regex issue - Replace floats, not int
Im want to remove all but the float in this sting:
string = "1 south african rand is 0.11044"
Im doing it like this:
reg = /[^\d+.\d+]/g
console.log string.replace(reg, '')
that logs
10.11044
...
2
votes
1answer
37 views
Regex in javascript with latin and turkish characters
I am trying to replace all the non latin/turkish characters, but something is wrong and I can't find it.
For example:
var texto = '*istediğiniz*';
if (texto.match(/[^a-zA-Z0-9şŞıİçÇöÖüÜĞğ\- ]/g)){
...
2
votes
5answers
53 views
RegExp: Match repeating sequence pattern of numbers
I am trying to write an RegExp that matches something like 01, 03, 05-08, 10 but does not match 01, 03, 05-08, (because the squence has to end with a number).
So basically my "string" consists of ...
0
votes
1answer
34 views
Javascript RegEx Object Double Escape Special Characters
I've checked out http://www.w3schools.com/jsref/jsref_obj_regexp.asp (not that I was too hopeful) and various questions here with no luck.
What I need is a method for double escaping c# special ...
0
votes
2answers
71 views
regexp special characters
I have searched and none of the existing answers works for me. My problem is as follows:
I have this code for RegExp that searches for match and highlights matching letters starting at the frist ...