Linked Questions
48 questions linked to/from How to escape regular expression special characters using javascript?
1 vote
2 answers
1k views
Match Non-Consecutive Duplicate Characters
For example: I want to match duplicate characters that are separated by other characters: Matching stress should return sss Matching lambda should return aa Matching moonmen should return moonmn I am ...
-2 votes
3 answers
2k views
Highlight matching keywords within a text string with bold font
I am creating function in which I will pass String and Specific text.The specific text should be bold in whole string. I want to achieve this but unable do that. Input string:-"Hi Hello boy Hello ...
0 votes
3 answers
633 views
Replace multiple occurrences of a string (url) in a textarea
Probably I am not able to achieve this because I don't know much about regEx. I have an array of unique links uniqueLinks. Whenever those links appear in the HTML code I have my textarea, I want ...
2 votes
3 answers
2k views
how to not render html tags in v-html in vuejs?
I want to make only matched string bold. Say, I have a string "Hello, World!" and user searched for "hello". I want to make something like this, "Hello, World!". I have ...
1 vote
2 answers
2k views
How to highlight the search-result of a text-query within an html document ignoring the html tags?
I have a string which has html content in it. Something like this const text = "My name is Alan and I <span>an</span> <div class="someClass">artist</div>." I render this ...
3 votes
2 answers
100 views
Why does not this string pass test function?
This is what I do: var input_string = "(1) (1) test.txt"; var reg = new RegExp('^\\(\\d+\\)\\s+' + input_string,'i'); var tested_string = "(1) (1) (1) test.txt"; alert(reg.test(tested_string)); // ...
0 votes
2 answers
1k views
How does one categorize a list of data items via many different category lists where each list contains several distinct category values?
I am new to JavaScript so I am struggling to even know where to start. Please can someone help me. I have what I have tried something as shown below but it is nothing like the desired output as I have ...
1 vote
2 answers
877 views
Regex replace text outside html tag
I'm working on an autocomplete component that highlights all ocurrences of searched text. What I do is explode the input text by words, and wrap every ocurrence of those words into a My code looks ...
1 vote
2 answers
1k views
Why is new RegEx not working properly
For some reason… When ever I try to get the Object.keys from replace.letters and use the Object.keys in a new RegExp joined by |… The new RegExp only recognize some of the Object.keys but not all of ...
2 votes
1 answer
628 views
PowerShell Replace value in JSON
In our Azure CICD Pipeline, we have an element where we are trying to deploy Policies. We have JSON file per policy in the repo and we bring all these json files together into one file as part of CI ...
0 votes
1 answer
1k views
Regular Expression error in mongodb if string contains arithmetic operators
using Mongodb in my meteor application I am making a query using regular expression to check if the name or code is already available in the database or not. In my string all the numbers and special ...
-1 votes
2 answers
765 views
How to replace part of a string with another string? [closed]
Here's what I'm trying to do. Honestly, I'm not even sure where to start. var text1 = 'ThE foX iS brown', text2 = 'the fox is brown the fox is brown THE FOX IS BROWN', index = text2....
0 votes
5 answers
336 views
Remove everything contained by a pair of parenthesis including the parenthesis itself in case they enclose a specific substring
I'd like to remove whole string if the string inside brackets has the word ppm. Simply remove whole bracket if the word ppm inside. How do I do this? "Menthol(0.3ppm)" ===> "...
-1 votes
2 answers
295 views
Why does this javascript regex return false?
I'm trying to write a regexp which should return true if a given string foo ends with the given string bar. E.g: function solution(str, ending) { var pattern = "/" + ending + "$/"; var regex = ...
0 votes
4 answers
742 views
How does one parse best each item of an ingredient list and does create a new object based on each parsing result?
I have this list of ingredients I am trying to make a regex to look for 1 cup , or 1 tsp or 1 tablespoon and so on..... I have made this regex but It doesn't work as well. I am trying separate ...