#jree fava lezzonz

1 messages · Page 1 of 1 (latest)

modern snow
#

cree f# lessons

reef wigeon
#

is there a minimum amount of numbers

#

the center of this is probably a group that repeats some unknown amount of times

#

but then the issue is how do you know which variant of a number it is

modern snow
#

might be just an empty string or space

#

if there are no numbers in the string, i just need to return 0

reef wigeon
#

this is pretty intense

#

i dont know how to make a "match this group or match this other group

#

like idk if you can put groups into the []

modern snow
#

my first take was like

#

"-?\\d+(e\\-?\\d+)|(\\.\\d+)?"
-? to test if there is a leading -
\\d+ to get the number
(e\\-?\\d+) to get the number after e
(\\.\\d+)? to get the .num2 if it exists

#

since if there is plus in the beginning i ingore it anyways

reef wigeon
#

oh right I forgot about |

#

what are you using to test it

#

also whats wrong with that one you sent

#

If I add some extra brackets the test input is working for me -?\\d+((e\\-?\\d+)|(\\.\\d+))?

modern snow
reef wigeon
#

its maybe different in java

vestal pond
#

why regex

#

you could just split by anything that isn't a number, sign or dot

reef wigeon
#

i'm not allowed to use .split or .trim, but i can use regex

vestal pond
#

so, don't split using either one of those

#

I'd do a isValidNumber function and then just push the parsed numbers to a List

#

or if you can use commons, you could use NumberUtils#isCreatable

#

depends on how many things you consider numbers

modern snow
#

1\n1.1 12345/1e10]-1e-2 here is the line to parse

#

idk

unreal trellis
#

did u solve it?

#

it doesnt sound that difficult using regex

#

it consists of just the number class, +- class (0 to 1 length), and some constants

#

unless i got it all wrong?

#

also when showing us regex, one \ is enough

#

else it looks like u're escaping backslash which u're not

#

if u're parsing just group it (named groups may provide help when debugging)