regex not working to replace numbers with enclosing brackets numbers

3 Ansichten (letzte 30 Tage)
barak ostraich
barak ostraich am 9 Jan. 2019
Bearbeitet: Stephen23 am 9 Jan. 2019
how can i replace 't1 w1 r2 (L2) d1 L12aa' with 't(1) w(1) r(2) (L(2)) d1 L(12)aa'
means replace every digit ot two after [twrL] only with the number with enclosing brackets
i've tryed this but its not working
regexprep('t1 w1 r2 (L2) d1 L12aa','([twLr])/(\d*/)','$1($2)')

Antworten (1)

Stephen23
Stephen23 am 9 Jan. 2019
Bearbeitet: Stephen23 am 9 Jan. 2019
>> regexprep('t1 w1 r2 (L2) d1 L12aa','([twLr])(\d+)','$1($2)')
ans = 't(1) w(1) r(2) (L(2)) d1 L(12)aa'
You might also like to try using my interactive regular expression tool, which makes it quick and easy to try out different regular expressions and see what outputs REGEXP returns:

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by