0

A very quick question.

Here is the expression:

/[a-zA-Z]{1,}/

I want this expression to match only those letters. But it also seems to match "=" (equals sign). Am I doing something wrong?

For example:

/\B#{1}(__){1}(F|OB){1}_{1}([a-zA-Z]{1,})={1}\B/

This should match: #__OB_someText= The problem is it also matches this: #__OB_someText== or this #__OB_someText====2 The equal sign should appear only once.

I probably don't understand much about these assertions: \b \B.

jszumski
  • 7,430
  • 11
  • 40
  • 53
VolosBlur
  • 4,363
  • 3
  • 14
  • 9
  • Your regex is ok - what are you running it in? – foundry Jan 11 '13 at 16:16
  • hmmm.. M42 is correct of course. Your regex will return the correct matched part if you (captured it) but you actually want it to _fail_ if = is not followed by a word boundary... – foundry Jan 11 '13 at 16:30
  • ...or did you intend \b, word boundary, at start and end? – foundry Jan 11 '13 at 16:37
  • Yeah, kinda. Anyway it's a bad question. I'll work by it by my self. – VolosBlur Jan 11 '13 at 17:58
  • It is a bad question because I'm not telling the whole picture. Forget about it. I just wanted to use that equal sign for something. It should tell something if it is there. – VolosBlur Jan 11 '13 at 18:01

1 Answers1

1

\B stands for NON word boundary, there is no non-word-boundary between = and =

use this regex instead:

/\B#(__)(F|OB)_([a-zA-Z]+)=[^=]/

{1} can be omitted

{1,} is the same as +

[^=] means any character that is not =

Toto
  • 89,455
  • 62
  • 89
  • 125
  • {1} can be omitted - yes. {1,} is the same as + - I like this one {1,} better. [^=] means any character that is not = - thank you ^^ – VolosBlur Jan 11 '13 at 18:03