I have a string and would like to match a part of it.
The string is Accept: multipart/mixedPrivacy: nonePAI: <sip:[email protected]>From: <sip:[email protected]>;tag=5430960946837208_c1b08.2.3.1602135087396.0_1237422_3895152To: <sip:[email protected]>
I want to match PAI: <sip:4168755400@
the whitespace can be a word so i would like to use .* but if i used that it matches most of the string
The example on that link is showing what i'm matching if i use the whitespace instead of .*
(PAI: <sip:)((?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4})@
The example on that link is showing what i'm trying to achieve with .* but it should only match PAI: <sip:4168755400@
(PAI:.*<sip:)((?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4})@
I tried lookaround but failing. Any idea? thanks
<, use[^<]*instead of.*(PAI:[ \w]+<sip:)((?:\([2-9]\d{2}\) ?|[2-9]\d{2}[ -]?)[2-9]\d{2}[- ]?\d{4})@See regex101.com/r/V10BMX/1 The pattern can be a bit shortened by removing superfluous escapes and using a character class to combine the space and hyphen using[- ]