Write a function extractVersion(text) that finds the first version number in a string and returns it. For 'oracle release 12.2c' the answer is '12.2'.
19, 12.2, 3.10.4.'v2.0', '19c' and '4.5-beta1' the versions are '2.0', '19' and '4.5'.'version 12.' return '12'.'3.10' stays '3.10', not a number).A regular expression with match finds the version in one step. Remember that match returns null when nothing is found.
extractVersion('oracle release 12.2c')Returns '12.2'
extractVersion('Python 3.10.4 released')Returns '3.10.4'
extractVersion('no version')Returns null
Asked at Oracle · Source
extractVersion('oracle release 12.2c')'12.2'extractVersion('Python 3.10.4 released')'3.10.4'extractVersion('no version')nullHidden tests run on Submit.