1

I need a regex that will get the name of a label. The labels look like this:

lbl LabelName

The regex will need to return LabelName. I manged to make this:

(?<=\slbl\s).+?(?=\s)

This works fine as long there is only one character between "lbl" and "LabelName". If I add two spaces or more spaces then it will return the extra spaces.

I tried (?<=\slbl\s+).+?(?=\s) but it doesn't work either.

2
  • I solved it using a without using a regex. I used a lexer that I created a while back. Commented Jul 22, 2011 at 3:50
  • Your comment could be added as an answer. Can you post it? (And the code for the lexer if it's short enough and you own it?) Commented Aug 2, 2011 at 17:49

3 Answers 3

2

Does the following regular expression work for you?

lbl\s+([^\s]+)
Sign up to request clarification or add additional context in comments.

Comments

1

Use this: ^lbl\s+(\S+)$. In 1st group you obtain LabelName.

Comments

0

You can keep the extra spaces with the 'lbl' part and still capture LabelName with something like this:

^lbl\s+(.*)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.