MartinS
Active Member
- Joined
- Jun 17, 2003
- Messages
- 490
- Office Version
- 365
- Platform
- Windows
OK so I have a tool that needs to check the syntax of a string is in the correct format, and have been working with 'Like', but have hit a limitation which means I need to create a lot more 'templates' than I'd like. So for example:
"2021_M_(1_50%_S7_5_W1%1%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W#%#%)" is True
BUT what I'd like is for the W#% to be any number between 1 and 100, but seems using the square brackets only works for single digits, i.e. [1-9] works, but [1-10] or [1-100] doesn't.
I currently have these three lines:
"2021_M_(1_50%_S7_5_W1%1%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W#%#%)" Or _
"2021_M_(1_50%_S7_5_W25%25%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W##%##%)" Or _
"2021_M_(1_50%_S7_5_W100%100%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W###%###%)"
Is there a way to have only one 'template' for these three? Am I better off switching to regular expressions?
Many thanks
Martin
"2021_M_(1_50%_S7_5_W1%1%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W#%#%)" is True
BUT what I'd like is for the W#% to be any number between 1 and 100, but seems using the square brackets only works for single digits, i.e. [1-9] works, but [1-10] or [1-100] doesn't.
I currently have these three lines:
"2021_M_(1_50%_S7_5_W1%1%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W#%#%)" Or _
"2021_M_(1_50%_S7_5_W25%25%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W##%##%)" Or _
"2021_M_(1_50%_S7_5_W100%100%)" Like "202[1-9]_[MF]_(#_##%_S#_#_W###%###%)"
Is there a way to have only one 'template' for these three? Am I better off switching to regular expressions?
Many thanks
Martin