Home > Blockchain >  Regex: How to extract a word with a preceding number and exclude numbers and colon after that group
Regex: How to extract a word with a preceding number and exclude numbers and colon after that group

Time:02-12

Consider the following strings:

1 Post 12:34

4 Posts 15:11

Deleted 8:46

I need to get the first part with the number and exclude the second timestamps: This is what I've tried, but I get null for "deleted".

var poststatus = posts.match(/(^)[\d](?<!^)[\D\:] /);

CodePudding user response:

Give this a try:

/(.| )*(?= \d :\d )/g

https://regex101.com/r/EvDkZr/1

  • Related