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
  • 23,259
  • 6
  • 48
  • 102
Kucharsky
  • 201
  • 3
  • 16

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
  • 10,622
  • 5
  • 14
  • 32