Unable to find patter in JS RegExp [duplicate] - javascript

This question already has answers here:
JavaScript regular expression "Nothing to repeat" error
(2 answers)
Why do regex constructors need to be double escaped?
(5 answers)
Closed 3 years ago.
I trying to identify regular expression in JS. Expression which wrote to identify the pattern is working in Online RegEx but when i use it in my own Code it does not work.
it says error .*|{1}/: Nothing to repeat
This is Expression -
Examples:\n.*\|{1}
Sample Data -
Examples:
|asda| asd|asd|adasda|adaasdsaasdasdsa|adsadsa|asdasdad|asdasdsd|asda |
Examples:
|Word| asd|asd|W#132|iam|GOto|asdasdad|asdasdsd|asda- |

Related

Handling special characters in Java script to enclose them in Square Brackets? [duplicate]

This question already has answers here:
Wrap Numbers in Brackets using javascript .replace regex
(1 answer)
Check for special characters in string
(12 answers)
Closed 2 years ago.
I am trying to write a Java Script function that should enclose all the special characters in the given String in a bracket like following -
Input ===> Output
123##$, ====> 123[#][#][$][,]
Changing All the special characters to certain String [ _ in this case] is easy -
string = string.replace(/[^a-zA-Z0-9]/g,'_');

Javascript - replace pattern but keep alphabets [duplicate]

This question already has answers here:
How can I replace a regex substring match in Javascript?
(4 answers)
How to replace captured groups only?
(7 answers)
Closed 3 years ago.
I was wondering, what is the best way to implement the following case:
vm.elasticQuery = userQuery.replace(/~='[a-zA-Z]+'/g,':*[a-zA-Z]+*')
In other words, I would like to replace every pattern that looks like this ~='SomeLetters' to a pattern that looks like this :*SomeLetters*. Take into account that I do not want to remove/change the alphabets but only the outside.
Your help is appriciated.

Regex Unexpected ^ and character match [duplicate]

This question already has answers here:
Javascript: Split a string into array matching parameters
(3 answers)
Closed 4 years ago.
I have this regular expression that tokenizes calculator input strings like 12+3.4x5 to 12,+,3.4,x,5
The regular expression used is
\d+\.?\d+|[\+-÷x]
I get an unexpected match with ^ and letters.
Regex solution, although there's probably a cleaner way of writing this if someone could point it out?
(\d+\.?\d+|\d+|(\+|-|÷|x))

Regex to get string between two specific tags [duplicate]

This question already has answers here:
Regular expression to get a string between two strings in Javascript
(13 answers)
What special characters must be escaped in regular expressions?
(13 answers)
Closed 4 years ago.
I have a string like:
[device]Some device[/device]
I am trying to write regex that will return only "Some device".
/[device](.*?)[/device]/i.exec(str) // doesn't work
/[device](.*)[\/device]/g.exec(text) // doesn't work
I am not sure how to extract it?
I already tried solution from Regular Expression to get a string between two strings in Javascript and it doesn't work for string like [][/]
[device]Some device[/device]
return
evice]Some device[/device] and all other strings.

Regular Expression jquery validation1 [duplicate]

This question already has answers here:
How can I validate an email address using a regular expression?
(79 answers)
Closed 5 years ago.
Can anybody share Regular Expression below example:
minimum 3 alphanumeric and then add only one '#' then again minimum 3 alphanumeric
example: rohit#tcs or himansu#infosys
Here is a pattern that matches:
/\w{3,}#{1}\w{3,}$/

Categories

Resources