I need your help to create a regex pattern to extract a character from the value of the attribute "name" of an html input.
This is because, with a button I clone dynamically a "select" and some input text, so I need to keep the same syntax of their attribute "name" value.
Example:
<input id="search-words02" type="text" name="words[1][element]">
<select id="search-words03" title="Auteur" name="words[1][target]">
  <option value="ALL">hello</option>
</select>
So I have words[1][element] and words[1][target]
And to submit the form in a json format with all fields dynamically cloned, I need to increment the words[1][element] and have words[2][element] or words[3][element].
So my json could be :
{
        "words":        {
            "0":
            {
                "element":"",
                "target":""
            },
            "1":
            {
                "element":"2",
                "target":"GES"
            }
            "2":
            {
                "element":"3",
                "target":"XXX"
            }
}
So I guess my pattern should take and replace the character in the first tab, but I have no idea how the regex should be to do that..
Anyone can help me to build this regex and tell me how I can replace the found term ?
 
     
    