Reputation: 20891
I get some text at intervals from stream like,
ICY Info: StreamTitle='Elvis Presley - Saved';StreamUrl='';
ICY Info: StreamTitle='Elvis Presley - Saved'
ICY Info: StreamTitle='Ivank'av T'ali - Yorua';StreamUrl='';
ICY Info: StreamTitle='Ivank'av T'ali - Yorua'
I wish to obtain
Elvis Presley - Saved
Elvis Presley - Saved
Ivank'av T'ali - Yorua
Ivank'av T'ali - Yorua
I'm using (?<=\=\').*(?=';S)
or (?<=\=\').*(?=')
but they seem not suitable.
@Edit: I have just come with (?<=\=\').*?(?=';)
.
Upvotes: 0
Views: 39
Reputation: 163362
(?=';S)
will not work for the first and the third example when ';S
is not there.
On the other hand (?=')
Will match too much in the first and the third example.
What you could do is use an alternation in the lookahead to check for either ;:
or '
followed by the end of the string.
(?<==').+?(?='(?:;|$))
Explanation
(?<==')
Positive lookbehind to assert what is on the left is ='
.+?
Match any character one or more times non greedy(?=
Positive lookahead to assert that what is on the right is
'(?:;|$)
Match '
followed by an alternation matching either ;
or assert the end of the string $
)
close positive lookaheadUpvotes: 1