Post 9tMLEGtCzdvDSpUPo0 by wictory@aatu.icante.ventures
(DIR) More posts by wictory@aatu.icante.ventures
(DIR) Post #9tKJK6RUI25L2MjH5E by karen@kawen.space
2020-03-24T08:28:43.181341Z
0 likes, 0 repeats
i honestly don't know if regex is stupid or if i'm stupid
(DIR) Post #9tKJQpHeU2zXqcKo9A by karen@kawen.space
2020-03-24T08:29:59.736242Z
0 likes, 0 repeats
`[a-zA-Z0-9]+` only matches the first character and the lets anything go? is that how it works??
(DIR) Post #9tKJtcnxxUSJXkBJpo by mezzodrinker@tooting.ch
2020-03-24T08:34:13Z
0 likes, 0 repeats
@karen Technically, this should only allow alnum characters. At least one, but with an unlimited upper boundary (cf. https://regex101.com/r/t8rdiH/1).It might be that, for validation purposes, you need to surround it with ^$, though, so that you get `^[a-zA-Z0-9]+$`.
(DIR) Post #9tKJtdC4VrjokVSZPM by karen@kawen.space
2020-03-24T08:35:12.262521Z
0 likes, 0 repeats
@mezzodrinker yeah i think that's what's wrong
(DIR) Post #9tKK4QeDV0l91Wlzeq by kura@fedi.z0ne.moe
2020-03-24T08:37:11.239502Z
0 likes, 0 repeats
@karen @mezzodrinker if you dont specify the limiter "^" [start of string] and/or "$" [end of string] it matches like "^.*[a-zA-Z0-9]+.*$"
(DIR) Post #9tKKTEgB8OBJ8zWHFA by mezzodrinker@tooting.ch
2020-03-24T08:39:49Z
0 likes, 0 repeats
@kura @karen Mh, not quite. Technically, what happens if you run a `match`/`matches` function in programming language X is that the input string is checked for substrings which match the specified regex. This makes it more or less a `contains` operation. The only way to work around this is by specifying ^ and $ to force the regex to apply to the entire input string.
(DIR) Post #9tKKTF2VnM2uGFy73Q by kura@fedi.z0ne.moe
2020-03-24T08:41:38.106995Z
0 likes, 0 repeats
@mezzodrinker @karen i meant as a simple validation function, whcih i assumed as a given in this case.if you want to grab the match area, your explanation is right.
(DIR) Post #9tKZTKTd4sGsRB9VjM by shmibs@tomo.airen-no-jikken.icu
2020-03-24T11:29:43.991727Z
0 likes, 0 repeats
@karen regexes are greedy, so they return the longest match they canmatch("aろp49", "[a-zA-Z0-9]+") == "a"match("ap49ろk31", "[a-zA-Z0-9]+") == "ap49"or so
(DIR) Post #9tMLEGtCzdvDSpUPo0 by wictory@aatu.icante.ventures
2020-03-25T07:59:31.366690Z
0 likes, 0 repeats
@karen it only has to match the first one, the rest is optional (obviously). What the algorithm actually does depends on whether it tries to find the longest match, shortest match or something else.