Tagged Questions
1
vote
1answer
29 views
javascript regex .match stop at a certain string
What should I add to this regular expression to stop the search at "/stopHere" and only return what it found up until that string?
var string = ...
0
votes
3answers
57 views
Regex to split lines in javascript
I want to split the following lines into an array in Javascript:
Jun 02 16:45:04 [steveh] [info] test1
Jun 02 16:45:12 [steveh] [info] test2
Jun 02 16:45:12 [steveh] [info] test3
test 3.1
test 3.2
...
2
votes
1answer
45 views
Regex: \b for strings that don't start with a word character?
Let's say I have the following string:
Lorem #test ^%#test ipsum#test dolor #test sit #testamet.
^^^^^ ^^^^^
What regular expression do I use to select only the ...
6
votes
2answers
50 views
transform '#ff00fffirstword#445533secondword#008877thirdword' to html tag format
Can I transform string #ff00fffirstword#445533secondword#008877thirdword to
<font color='#ff00ff'>firstword</font><font color='#445533'>secondword</font><font ...
0
votes
0answers
27 views
regex for mongodb url string, javascript
I'm a bit stucked with this regex problem, I need to check if url has at start mongodb:// and at the end of a string - port with numbers :27017 and also if there is no slash / .
For example:
...
0
votes
1answer
34 views
How to do find/replace case insensitive only in the beginning part of the string?
I want to remove "I will" at the beginning of a string. Those "I will" words could be uppercase/lowercase, so I will need to match for case insensitive. But I only want to remove those words if they ...
0
votes
5answers
46 views
How do I remove all symbols from the beginning and end of a string, if any?
Keep only the alphabet and numbers.
--I have a dog!!! should result in I have a dog
I have a dog. should result in I have a dog
0
votes
3answers
49 views
Removing substring from string using Regex javascript
I have a string in javascript like this:
frmSearch=FeeType=RecordingSpend:LoginID=:PersonCalled=:FeeAmount=22.234567:Paid=
I want to remove :FeeAmount=22.234567 part from this string using Regex or ...
0
votes
2answers
20 views
Replace @mention with link
I am looking to replace any @mention in a string with <a href="http://twitter.com/mention">@mention</a> using Javascript or jQuery. I have the function from the second answer of How to ...
3
votes
1answer
54 views
Remove Unicode characters within various ranges in javascript
I'm trying to remove every Unicode character in a string if it falls in any the ranges below.
\uD800-\uDFFF
\u1D800-\u1DFFF
\u2D800-\u2DFFF
\u3D800-\u3DFFF
\u4D800-\u4DFFF
\u5D800-\u5DFFF
...
1
vote
1answer
41 views
Javascript regular expression
I am making form and there is only one more thing which I cant figure it out :(
I need regular expression for password which must be at least 7 characters long. There can be small and big letters ...
-1
votes
2answers
32 views
How to retrieve a youtube playlist id using Regex and JS
I'm trying to retrieve playlist ids from youtube links like:
https://www.youtube.com/watch?v=hv_X327YUdI&list=SPGznEl712WelO6ZhS8lc2ssweLuQaCKld
or
...
0
votes
2answers
47 views
Javascript replace dots with reguler expression, but not works
Im sorry, but i can't find working dot replacement on stackoverflow.
Peoples ask about replacing
var str = '. 950.000.000, -';
str = str.replace(/\./gi, '');
alert(parseInt(str)); // yes, it works ...
0
votes
2answers
30 views
Javascript regex to extract the string before the last backslash [duplicate]
I am dealing with timezone's in Javascript and I need a regex that will extract everything, but the timezone name from it. For example, I have the timezone America/Argentina/Buenos_Aires. I want to ...
0
votes
2answers
41 views
Regular Expression Replace in Javascript
Test 1
Test & Test 2
Test,Test 2
Test-Test2
Test/Test2
Test. Test2
Test 1 Test 2 Test 3
Test 1 Test 2 - Test 3, Test 4, Test 5
I have the following string array, I need to replace this via ...
2
votes
3answers
37 views
Regex catch string between two strings, multiple lines
I´m working on a *.po file, I´m trying to catch all the text between msgid "" and msgstr "", not really lucky, never more than one line:
msgid ""
"%s asdfgh asdsfgf asdfg %s even if you "
"asdfgdh ...
0
votes
2answers
52 views
jQuery - getting error for square brackets in name attribute
I know there are already a lot of posts in SO regarding this issue. But none of them works for my case.
I've multiple select inputs with the following naming format:
select ...
4
votes
2answers
63 views
Can someone please explain this regex filtering of an array
I'm filtering an array, and found a regex on here.
I'm trying to understand this:
filterArray.filter(/./.test.bind(new RegExp(key, 'g')))
But I don't understand how the array tests it value against ...
0
votes
3answers
33 views
How to take content from json using regular expression (regex) in php
I need to extract json which is existing inside some html tags. how to extract name(key) values from below json using regular expression
<div id="gwt_products_display_results" ...
0
votes
1answer
21 views
jQuery validate phone number input with the igorescobar Jquery Mask Plugin
I'm using the Jquery Mask plugin to validate a phone text input like so:
http://igorescobar.github.io/jQuery-Mask-Plugin/
$('#phone').mask('(999) 999-9999');
How can I use a regex expression to ...
1
vote
1answer
38 views
Using JavaScript RegExp to valid email. Regex special characters not working
I've got this JavaScript function:
function emailaddresscheck() {
var emailregex = new ...
-2
votes
1answer
57 views
JavaScript Regex formating string
I'm having difficulties in executing what I want to achieve, it may just be sleep deprivation but it's more likely that regex is not my strong suit, I just can't quite get my head around it, but ...
-5
votes
3answers
66 views
Javascript regular expression [closed]
I need to get the id from an url like this: Id is positive int.
And I to try do this with regexp:
url = 'http://127.0.0.1:8000/api/v1/customer/3/'
url.match('///d/')
But this pattern doesn't work.
...
11
votes
4answers
181 views
Regex reads from right to left
I was looking for a short code that can put commas in set of numbers until I came to this site.
The code:
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
...
1
vote
1answer
47 views
Combine two regex condition using or
I have one regex to check below conditions in javascript
at-least 1 number
could be alphanumeric
special character allowed would be - , space, #
var regex= new RegExp (/^(?=.*\d)[a-zA-Z\d #-]+$/);
...
0
votes
2answers
26 views
Match suffixes s and ed in regex - javascript
I am using this regex to match words in an html page.
\b(wordtosearch)\b(?!')
The forward negative lookhead is to prevent matching words having ' like don in don't
however i also want to match ...
0
votes
1answer
23 views
How I can get multilingual values of a variable in a string with NodeJS?
In NodeJS, I am getting tags comma seperated, an in my model, split them and save to DB.
var getTags = function (tags) {
return tags.join(',')
}
var setTags = function (tags) {
return ...
1
vote
6answers
53 views
jQuery function for check textbox
I’d like use jquery function that validate a input field. This input field must be used for entering 11 digit numbers that start with 0.
I tried some function but doesn’t work!
function ...
0
votes
3answers
50 views
javascript regex to remove whitespace fails, why?
I use text.replace(/\s/g, '') to remove all whitespace characters from a String.
I'm trying this on a russian text. I do an alert(text) which shows me the correct string, but the replace function ...
0
votes
4answers
44 views
How to extract the last substring using JavaScript regular expressions?
I am new to regular expressions. I am trying to use JavaScript regular expressions to extract the last substring within parentheses from a string. It's not working for me. Instead, I'm getting the ...
0
votes
1answer
58 views
phone number regex not working
I have a form with an input that follows this pattern:
pattern='(\+|00)\d{2,3}[-]\d{8,10}'
an example would be +999-123456789
I have to form validate it again using javascript and have tried to ...
1
vote
5answers
73 views
regex to replace all leading “>” with only one “>”
How do I make an expression to match and replace all leading > with only one >
I tried using ^>(.*?)[^\W]+ but that doesn't seem to be working for all cases.
Some of the possible cases:
...
0
votes
2answers
47 views
Javascript regex split for special characters
Have a look at this fiddle http://jsfiddle.net/yeXWv/
Here I want to split the characters which starts with [* or [*# and ends with *]. The current regular expression split the string which starts ...
0
votes
5answers
37 views
Alphanumeric JavaScript RegEx for Password Validation
I'm using a regex below to validate password to accept alphanumeric characters only. The regex works if I enter 2 characters one alpha and one numbers but if more than two characters my regex doesn't ...
0
votes
2answers
40 views
Replacing a substring only if it is present outside the quotes not inside the quotes in javascript
/+(?=([^"\\]*(\\.|"([^"\\]*\\.)*[^"\\]*"))*[^"]*$)/g, "&&"
I used this regex it replaces + by && but how do i replace a string line "and" by "&&"
str = "Loop(this and that ...
1
vote
1answer
39 views
use of regex to find a pattern and get the result
I really have a hard time with Regex expressions and I'm trying to do a string search and get the value that was found with regex.
At this point I'm using a lot of .indexOf() and .substring() and so ...
0
votes
1answer
28 views
how to find the matching string between '{ } ' in node.js
My sample string is
var str = "My name is {name}.from {area}";
I need both {name} and {area} separately from that string.
I TRIED
var s = "My name is {name}.from {area}";
var matches = ...
0
votes
3answers
41 views
regex pattern for alpha numeric value
I want a regex pattern allowing only alphanumeric value, neither only alphabets nor digits, having minimum length = 4 and maximum length = 15,
I tried using /^[a-zA-Z0-9]{4,15}$/ , but this pattern ...
0
votes
3answers
39 views
replace all without a regex where can i use the G
So i have the following:
var token = '[token]';
var tokenValue = 'elephant';
var string = 'i have a beautiful [token] and i sold my [token]';
string = string.replace(token, tokenValue);
The above ...
0
votes
2answers
19 views
Matching Second part of MIME Content Type using RegExp
I've seen a number of examples on StackOverflow to get the "second" part of a MIME content type. What I'd like is, when provided with: text/html; charset=ISO-8859-1
I'd like to return just: html
The ...
1
vote
2answers
55 views
regular expression javascript returning unexpected results
In the below code, I want to validate messageText with first validationPattern and display the corresponding message from the validationPatterns array. Pattern and Message are separated by Pipe "|" ...
1
vote
4answers
71 views
Regex text between tags not found [duplicate]
I am trying to match the word contact within content/text of html tags. I can get all text between tags:
http://rubular.com/r/IkhG2nhmnS
with:
(?<=\"\>)(.*?)(?=\<\/)
But I want to search ...
3
votes
3answers
63 views
Is there a more concise regex to match a-z except for characters e, n, p?
I want to write a regex to match characters a-z except for e, n p. I can write:
[a-df-moq-z]
I'm just wondering if there's a way to write something like ([a-z except ^enp]) just to make the regex ...
2
votes
1answer
34 views
Can I use a regular expression in querySelectorAll?
On a page I'm doing I will be ending up with custom link elements like this:
<link rel="multiply" type="service/math" src="path/to/service">
<link rel="substract" type="service/math" ...
0
votes
1answer
45 views
need help on a regular expression
I need some help on constructing a regex, please.
I have an array of domain names and an array of TLDs (quite long). example:
tlds = {
'.com':{
1 : '£4.00',
2 : '£7.50',
...
0
votes
2answers
29 views
Using Regular Expressions for Search/Replace
I have a String like this item width200height300. The values of width an height may be different. Like this
item width100height100 or item width50height300.
How can you search and replace ...
0
votes
1answer
67 views
Can someone explain what this regex do?
It's part of code where javascript should watch for some price and match if it's lover than required, but i don't understand regex quite well and it's obvious that the error is in there.
So on a ...
0
votes
2answers
29 views
Highlight matched text with case sensitive for auto suggestion
I am working for auto suggestion, where i need to match the key term and if the key term matched make it highlighted. I am done with this but the problem is while matching I am looking with ignore ...
0
votes
1answer
43 views
preg_match php to match javascript
i have this function in php :
$html_price = "text text 12 eur or $ 22,01 text text";
preg_match_all('/(?<=|^)(?:[0-9]{1,3}(?:,| ?[0-9]{3})*(?:.[0-9]*)?|[0-9]{1,3}(?:\.?[0-9]{3})*(?:,[0-9] ...
1
vote
2answers
45 views
jQuery get css properties based on regex
I'm trying to build some custom js for an app, and I've got to a point where I need to replicate some css styles from a parent item.
...
match_properties: ['background-color', 'border-radius', ...