0

I am trying to create a RegEx that will find the string

02075517[

However this string sometimes has spaces so I would need it to match

020 75517[

and

0207 5517[

and

020 7551 7[

etc.

I've tried using this site here: http://www.regexr.com/ but can't quite get there.

Thanks very much

Ed

2
  • remove all the spaces then match with the numbers. No need for any regex. Simply use equals Commented Nov 4, 2014 at 11:58
  • Sorry perhaps I should have explained I am using regex with a tool called AJC Grep that searches word documents for strings Commented Nov 4, 2014 at 12:25

1 Answer 1

1

You can define a group to be matched. ([0-9 ]+\[) will match multiple numbers or spaces followed by a square bracket. See http://www.regexr.com/39rhh

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

4 Comments

Unfortunately this doesn't work because if the document contains 020a7551[ then it matches the 7551[ but I want to reject it because although there is 020 there is something that isn't a space i.e. 'a'
Would there be an expression to match 020 + anything that is a number or space + 7[
Yes, simple put it at the beginning: (020[0-9 ]+\[) regexr.com/39rht
or if you want a 7 in front of the square bracket: (020[0-9 ]+7\[) regexr.com/39ri0

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.