search - Replacing *target* characters in RegEx without losing anything -


parameter

in sublime text 3 using following regex code search combo find any alphabet character preceding 0, followed space, followed character follows:

regex code

[a-z]0 [a-z] 

search target examples

eg.1  a0 p eg.2  p0 sa eg.3  ap0 l 

question: regex code should write replaces such occurrences containing 0s dot (.) i.e., should become this:
replace objective of target examples

eg.1  a0 p    → a. p eg.2  p0 s    → p. sa eg.3  ap0 l   → ap. l 

use capturing groups , backreferences:

regex: ([a-z])0( [a-z])
replacement: $1.$2

see regex demo

details:

  • ([a-z]) - matches , captures group 1 ascii lowercase letter
  • 0 - literal 0 matched
  • ( [a-z]) - group 2: space , lowercase ascii letter

the replacement contains backreference value stored in group 1 ($1), replace 0 dot, , use backreference group 2 contents ($2).

enter image description here


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -