regex not working to replace numbers with enclosing brackets numbers
    4 views (last 30 days)
  
       Show older comments
    
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)')
0 Comments
Answers (1)
  Stephen23
      
      
 on 9 Jan 2019
        
      Edited: Stephen23
      
      
 on 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:
0 Comments
See Also
Categories
				Find more on Characters and Strings in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
