Input Text -
hey, G Suite , ,Social Media Wall, Social Media Wall , ERP ERP Corecon
Query -
((?<=[,-./\s])(ERP Corecon|Social Media|Social Media Wall|ROI|ERP)\b)
Output -
hey, G Suite , ,**Social Media** Wall, **Social Media** Wall , **ERP** **ERP Corecon**
Ideal Output - Social Media & Social Media Wall both should be matched
regex link - https://regexr.com/6ugr5
CodePudding user response:
You may be able to use this regex:
(?<=[,-./\s])(ERP(?: Corecon)?|Social Media(?: Wall)?|ROI)\b
RegEx Breakup:
(?<=[,-./\s]): Lookbehind to assert presence of these chars before current position(; Start capture groupERP(?: Corecon)?: MatchERPorERP Corecon|: ORSocial Media(?: Wall)?: MatchSocial MediaorSocial Media Wall|: ORROI: MatchROI
): End capture group\b: Word boundary
CodePudding user response:
You could try to use named groups:
(?<SocialMediaWall>(?<SocialMedia>Social Media)( Wall)?)|(?<ERPCore>(?<ERP>ERP)( Corecon)?)|(?<ROI>ROI)
As you can see, the SocialMedia group is nested inside the SocialMediaWall group. That's a way of getting both values.

