Skip to content

Identify words that may contain numbers without selecting numbers #911

Answered by notpeter
LordGolias asked this question in Q&A
Discussion options

You must be logged in to vote

Based on the first version of your code word doesn't match 3a33aa because word specifically begins with a required (ASCII_ALPHA|"_") so it's never going to match things that start with a number. Change that to be more permissive:

word      = @{ (ASCII_ALPHANUMERIC | "_")+ }

If you put number before word in base_term it will greedily capture numbers (3 and 33) and things like 3a33aa will fall through and be captured by word.

base_term = @{ string | number | word | symbol }

If that isn't enough, can you provide a little more detail:

  1. Examples of what you are trying to parse? (both success and failure)
  2. Whether you're using implicit whitespace (and if so what value you have for WHITESPACE)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tomtau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants