match in awk

radix655
radix655 used Ask the Experts™
on
In reference to the question:
http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Q_27239799.html

if sample.log is
like
[Source<25101>=sr2][SourceSystemCode<25102>=sr3][Sample<24>=0.9]
[Source<25101>=source3][OrderId<25103>=101][Sometag<25>=100]

how can I use match in awk?

When I am using this, it is giving wrong result.
bash-3.2$ awk '{ match($0, /Source<25101>=(.*)]\[(A-Za-z)*/, arr); print arr[1] }'  sample.log


sr2][SourceSystemCode<25102>=sr3
source3][OrderId<25103>=101

It is supposed to be
sr2
source3


Please suggest.



Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Test your restores, not your backups...
Top Expert 2016
Commented:
Give this a try.

{ match($0, /Source<25101>=([^\]]*)\]/, arr); print arr[1] }

~bp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial