regex - Regular expression with positive lookahead/lookbehind -


how can match below strings single regular expression?

this regular expression i've tried: (?<=.+)site(?=.+)

note simpler regular expressions might job, whole point of learn (?<=.+) , (?=.+) parts of regular expression do.

locationasite1 locationasitenumber1 locationasitenumber01 locationasite01 locationbsite.01 locationb.site.02 (locationb)site.02 <locationb>site<03>s ..locationb..site<03> 

your regex may written as,

(?<=.)site(?=.) 

which means, string site must preceded , followed atleast 1 character.

most languages won't support variable length lookbehind except c# family.

(?<=.+)site(?=.+) 

means substring site must preceded , followed 1 or more chars. is, match string site if it's @ middle not if it's present @ start or @ end.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -