chirag patel chirag patel - 1 month ago 5x
jQuery Question

How to get all the word using a match from the string

My string is :

str = {!Chirag patel&gt;1|2|3|4|5}<br /><br />asdadasd<br /><br />{!Test&gt;T|E|S|T}<br /><br />Chirag patel<br /><br />{!HELLO&gt;H|E|L|L|O}

How i will get below result using a str.match in array:

0: Chirag patel&gt;1|2|3|4|5
1: Test&gt;T|E|S|T
2: HELLO&gt;H|E|L|L|O

I already tried below code:


but it give me only one match , but i want all the match

I want to replce my find word using like as below.

if i find :
Chirag patel&gt;1|2|3|4|5

then i want a below code is replace in to the string.

<div><select class="template-field" data-field-name="chirag patel">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
<option value="">4</option>
<option value="">5</option>


You may do as follows;

var str = "{!Chirag patel&gt;1|2|3|4|5}<br /><br />asdadasd<br /><br />{!Test&gt;T|E|S|T}<br /><br />Chirag patel<br /><br />{!HELLO&gt;H|E|L|L|O}",
matches = str.match(/[^\{!]+(?=\})/g);