-2

I am writing as ..

lets say we are finding a regexp of 7 then the multiple of 7 in reg exp would be [7|14|21|28]

does this seems resonable? please let me know..

Alan Moore
  • 73,866
  • 12
  • 100
  • 156
user3259486
  • 139
  • 1
  • 1
  • 7

1 Answers1

1

[7|14|21|28] matches any character 7, |, 1, 4, 2, 8.

To match 7 or 14 or 21 or 28, you should use group ((...)) instead of set of characters ([...]):

(7|14|21|28)
falsetru
  • 357,413
  • 63
  • 732
  • 636
  • when you say matches characters like 7, |, 1, 4, 2, 8 what do u mean? does [7|14|21|28] not mean that the expression is a multiple of 7 with 4 outputs? also my aim is to find the regexp that will match for lets say multiple of number 7 .. what do you mean by use group? – user3259486 Feb 01 '14 at 02:44
  • @user3259486, `[...]` matches any character inside it. For example `[ABC]` matches `A` or `B` or `C`, not `ABC`. – falsetru Feb 01 '14 at 02:45
  • But the reg exp that would match the multiple of 7 would have infinite number.. how would I write a exp that would fit in a [] bracket? – user3259486 Feb 01 '14 at 02:48
  • @user3259486, To get matches for multiple of 7. You'd better to match any numbers (`\d+`), and filter it using programming language. BTW, what programming language do you use? – falsetru Feb 01 '14 at 02:49
  • @user3259486, `\d+` is equivalent to `[0-9]+`. – falsetru Feb 01 '14 at 02:50
  • i am using jflex. I am still not understanding how this could result to the regex for the integer that would be a multiple of 7 ... I am sorry to ask but could you please give me a detailed knowledge of your understandings. – user3259486 Feb 01 '14 at 03:37
  • @user3259486, I don't know about jflex well. Here's [Python example](http://ideone.com/G5b9RF). I wish this help you. – falsetru Feb 01 '14 at 03:42
  • I am actually looking for a regular expression match for a multiple of a positive dec. number(7 for example). I need how to find the regular exp. – user3259486 Feb 01 '14 at 04:23
  • @user3259486, Do you mean numbers that does not follow `-`? Then, try `[-\d]+` and filter out negative numbers afterward. – falsetru Feb 01 '14 at 04:25
  • I dont have enough knowledge to understand your statement. what do you mean by follow -? and how can I use or try [-\d]+ ? Please be elaborative. – user3259486 Feb 01 '14 at 04:41
  • My aim is to find the regular expresion match of a positive decimal integer number 7. – user3259486 Feb 01 '14 at 04:41