I’m trying to implement a number range using the gsub function between 1-200, but I couldn’t find any good examples. I’m implementing a bbcode system where a user should be able to enter something like
[size=80]Hello world[/size]=> Valid[size=200]Hello world[/size]=> Valid[size=201]Hello world[/size]=> Invalid
This is currently what I have being fed into the gsub method and it accepts anything between 1-999:
\[size=(\d{1,3})\](.+?)\[\/size\]
try with this:
/\[size=(?:200|1\d{2}|[1-9]\d?)\](.+?)\[\/size\]/my testing program:
output: