0

I have a string like this :

[01/09/2015 00:00:47]       INFO=54646486432154646 from=steve   idfrom=55516654455457       to=jone       idto=5552045646464 guid=100021623456461451463   n
um=6    text=hi my number is 0 811 22 1/12   status=new      survstatus=new

I want to extract the text field, the result should like this :

hi my number is 0 811 22 1/12

This is what I tried as regex :

text=(.*)status

And it gives me this :

hi my number is 0 811 22 1/12   status=new      survstatus=new

So it's not what I want, how can I get rid of two last fields?

Thanks.

hawarden_
  • 1,904
  • 5
  • 28
  • 48

3 Answers3

1

I'd use:

\btext=(.*?)\bstatus=

in order avoid matching status in hi my status is 0

Toto
  • 89,455
  • 62
  • 89
  • 125
0

So the answer is text=(.*?)status, thank @HamZa for the quick answer.

hawarden_
  • 1,904
  • 5
  • 28
  • 48
0

It looks like your data is tab-delimited. If that is the case, this is probably better:

\ttext=([^\t*])

Which basically says, find a tab followed by 'text=' and then capture everything up until the next tab.

Abdul Aziz Barkat
  • 19,475
  • 3
  • 20
  • 33
Cargo23
  • 3,064
  • 16
  • 25