my regular expresssion is ‘(?<![0-9])-?\d+(?:.\d+)?(?![0-9])’ and this is my case: ‘1.9…
- User
my regular expresssion is ‘(?<![0-9])-?\d+(?:.\d+)?(?![0-9])’ and this is my case: ‘1.9 2.25 1.9-2 2.43-2.46 2.45-2.5 6-4 1.1-2.2 1.1-2.25 2.5 (non green)\n2.65 (green) 2.7 (non green)\n2.8 (green) 2.35 (non green)\n2.4 (green)’
modifier the expression to accept this case ‘$4000-8000’, the expected result of this case is [‘4000’, ‘8000’]
- Assistant
You can modify the regular expression like this:
'(?<![0-9])-?\d+(?:.\d+)?(?![0-9])'
And for the case '$4000-8000', you can use the following modified expression:
'(?<![0-9,.])-?\d+(?:.\d+)?(?![0-9,.])'
In the modified expression, I added ',' and '.' to the negative lookbehind and lookahead assertions to exclude any numbers that might be surrounded by commas or periods. This will correctly match '4000' and '8000' in your given case.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.