0

I have a string:

User{self=https:example.com, name=S1234, displayName=Johny B, accountId=null, emailAddress=johny.b@example.com, active=true}'

I try to capture group and get Johny B in sed. I have proper regex: displayName=(.*?),

but below sed command return me all string:

's/.*displayName=\(.*?\),/\1/'
Enlico
  • 17,834
  • 5
  • 39
  • 78
Kucharsky
  • 105
  • 11

1 Answers1

1

You can try this sed

sed -E 's/.*displayName=([^,]*).*/\1/' $file

You have further strings after the match which you need to account for.

HatLess
  • 5,048
  • 4
  • 8
  • 28