Linked Questions
12 questions linked to/from Replacing the nth instance of a regex match in Javascript
1
vote
1
answer
1k
views
Matching the nth occurrence of a single character in regex [duplicate]
I am having trouble finding any regex which actually matches what I need, despite how easy this request seemed when I started out. Hoping to get help here.
An early mistake in our code is sending ...
9
votes
5
answers
13k
views
How can I replace a match only at a certain position inside the string?
So, I have a function which has two params: string and match index to replace and i need to replace only match with that index. How can i do that?
Example:
replace('a_a_a_a_a', 1)
Result:
a__a_a_a
1
vote
3
answers
4k
views
Regular expression to match number in the middle
The following string represents a viewmodel property and in this case it has 3 different indices:
PROGRAMA_FASES[1].PROGRAMA_FASE_REPLICAS[0].PROGRAMA_FASES.PROGRAMA_PREGUNTAS[2].Value
I'm using ...
4
votes
2
answers
2k
views
javascript split regex bug in IE7
I am trying to split with this regex ({[^{}]*}) in javascript and I get different result btw IE7 and FF. The firefox result is the right one.
<style>
.box.round {
border-radius: 10px;
}
<...
0
votes
3
answers
2k
views
Replace string using regular expression at specific position dynamically set
I want to use regular expression to replace a string from the matching pattern string.
Here is my string :
"this is just a simple text. this is just a simple text. this is just a simple text. this ...
2
votes
2
answers
681
views
Regex Replace $nth element with Javascript
Is it possible that I replace the $n element with a particular string?
In my example the $1 element.
For example, i want to replace the last element of a url
"http://my.domain.com/sub/file.extension"...
1
vote
2
answers
356
views
How to use regex to format a comma separated map structure
Using a text editor, without writing JavaScript functions (e.g. can't use this great answer: Replacing the nth instance of a regex match in Javascript)
How do I take something like this (a ...
0
votes
2
answers
308
views
Replacing selected with another text
I am trying to replace selected text with another text.
Consider following is the line of text.
Hello world.Good morning. Hello world. Good morning.
Here if I select second morning text and I want ...
5
votes
1
answer
314
views
assigning index to text of div jquery
We have a html div (first image) and array of strings (see second image)
We have to assign the single index like safety[A4] and safety[A5] to the text of div.
But currently it assign two footnote ...
1
vote
3
answers
235
views
PHP Bolding The 'x' Instance of a Variable In a String
Basically I have a variable which contains a few paragraphs of text and I have a variable which I want to make bold within the paragraphs. (By wrapping <strong></strong> tags around it). ...
-2
votes
5
answers
82
views
Reg Expression - In javascript how can I get the 2nd instance?
I have a string like:
some people may work for some thing new.
I need to fetch the 2nd instance of the word 'some' using javascript reg exp.
how can i get that?
here is my try:
var text = "some ...
-3
votes
2
answers
47
views
jquery / JavaScript replace xth occurrence
I have a string like this:
var str = "A A A A A";
how do I replace a specific A with something else?
Eg: replace 3rd A to:
var str = "A A 00 A A";
Of the 1st, 2nd, etc.. ?