I have this type of text:
!D este caro 1 C este descgiderea C1 este alta deschidere Deschiderea de 1C este cu 2C 2D 3 D 1NT 2D 123456P
This easy regexp:
/([0-9][CDHS])/g
selects "1C","2C","2D","2D" (a digit immediately followed by [CDHS], anywhere in the text) .
What I want is to select only the letter from the sequences above (from "1C" -> only C, from "2D" only D, and so on...). How do I do that with a regexp?
le : While Bolo's method is indeed working in RegExr , in Jquery it appears it doesn't :(
Here's the code :
$(document).ready(function()
{
var de_inlocuit = [/!C/gi, /!D/gi,/!H/gi,/!S/gi,/(?<=[0-9])[CDHS]/g];
var replace = ['<img src="/sites/default/files/c.gif"/>', '<img src="/sites/default/files/d.gif"/>','<img src="/sites/default/files/h.gif"/>','<img src="/sites/default/files/s.gif"/>','test' ];
//<img src="/sites/default/files/c.gif"/>
var i=0;
for (i=0; i < de_inlocuit.length; i++)
{
$('body table tr td').replaceText( de_inlocuit[i], replace[i] );
}
});
The behavior is normal if I remove /(?<=[0-9])[CDHS]/g
, but since it was inserted into the code it doesn't even replace the other (surely) working regexp .