-1

sorry about simple question.

I need to check if the string include, this pattern.

somestring 532:

for more information, string + one space + number > 0 + ':'

Sungguk Lim
  • 5,710
  • 6
  • 38
  • 60
  • an what did you try already? – lejlot Apr 09 '14 at 12:26
  • I've tried RegExp("somestring [0-9] :") – Sungguk Lim Apr 09 '14 at 12:27
  • what if your somestring got an space ? – Fisherman Apr 09 '14 at 12:28
  • I suggest we remove the downvotes and simply ask the OP to include what he has tried, in the question. – sshashank124 Apr 09 '14 at 12:28
  • ok sorry, i'm fairly bad in english so i cannot describe my question enough. i'll delete this question. – Sungguk Lim Apr 09 '14 at 12:28
  • We understand what you mean. Simply adding what you have tried and why it didn't work will be sufficient to create a good question. – sshashank124 Apr 09 '14 at 12:29
  • yep honestly this question is my bad. I was struggled to get profer Regular expression, so I asked without any descritption. I apologize my bad – Sungguk Lim Apr 09 '14 at 12:33
  • This is partially addressed in the [StackOverflow Regular Expression FAQ](http://stackoverflow.com/a/22944075/2736496). Relevant answers: [Validating a string is a number](http://stackoverflow.com/a/4247184/578411) and [Validating a number falls within a min-max range (such as 1-31)](http://stackoverflow.com/a/22131040/2736496). Section: "Advanced regex-fu > Common validation tasks > Numeric", which is about 2/3 down. – aliteralmind Apr 09 '14 at 13:04

2 Answers2

2

You can try with following regex:

^[a-zA-Z]+ [1-9]\d*:$
hsz
  • 136,835
  • 55
  • 236
  • 297
1

You can just do:

([a-zA-Z]+)\s([1-9]\d*):

sshashank124
  • 28,066
  • 8
  • 58
  • 71