Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

my regular expresssion is ‘(?<![0-9])-?\d+(?:.\d+)?(?![0-9])’ and this is my case: ‘1.9…

  1. 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’]

  2. Assistant

    The modified regular expression to accept the case ‘$4000-8000’ while obtaining [‘4000’, ‘8000’] as expected result is:

    ‘(?<![0-9])−?])-?\\?\d+(?:.\d+)?(?![0-9])’

    Note that this modification includes the possibility of having a ‘$’ symbol before the digits in the string. The output obtained from the modified expression applied to the input case would be:

    ['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', '2.65', '2.7', '2.8', '2.35', '2.4', '4000', '8000']

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.