1

I want to find a string in 3 types of inputs :

  1. Client XXX.MYDOMAIN.COM is
  2. Client YYY is
  3. Client ZZZ.mydomain.com is

What I want is :

  1. XXX
  2. YYY
  3. ZZZ

Can someone help me with this. Thank you.

4
  • 1
    What have you tried already, and whats wrong with just looking for the second word? Commented Apr 3, 2014 at 18:26
  • So basically you want to match the word after Client ? Commented Apr 3, 2014 at 18:28
  • I want to match the word between 'Client' and 'is' . What I just found is the regex does not match if the there is dot(.) as part of the name. Commented Apr 4, 2014 at 14:42
  • Breaking apart components of a hostname is a solved problem. There is probably existing code that has been written, tested and debugged in whatever language you are using. Commented Apr 4, 2014 at 17:55

2 Answers 2

1

Try this regex:

(?<=Client\s)\b\w+\b 

see demo here: http://regex101.com/r/lQ9hD0

Sign up to request clarification or add additional context in comments.

Comments

1

This matches to the 3 example strings after Client:

Client (XXX|YYY|ZZZ) 

Or if you would like to match anything 3 character:

Client (...) 

1 Comment

...or Client\s+(\w+). The main point is, capturing groups are more widely supported than lookbehinds, and much more flexible.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.