$regexp nested inside another $regexp not working using captures

$trim($regexp('Genre 1 with Space, Genre 2 with Space, Genre 3 with Space','(,*)\s*([^\,]+[^,\s])','$1 [url=https://urlhere.com?taglist='$regexp($2,\s+,.)']'$2'[/url]'))

Should output:
[url=https://urlhere.com?taglist=Genre.1.with.Space]Genre 1 with Space[/url], [url=https://urlhere.com?taglist=Genre.2.with.Space]Genre 2 with Space[/url], [url=https://urlhere.com?taglist=Genre.3.with Space]Genre 3 with Space[/url]

[url=https://urlhere.com?taglist=Genre 1 with Space]Genre 1 with Space[/url], [url=https://urlhere.com?taglist=Genre 2 with Space]Genre 2 with Space[/url], [url=https://urlhere.com?taglist=Genre 3 with Space]Genre 3 with Space[/url]

Should the nested $regexp($2,\s+,.) not take care of replacing any whitespaces with .

A workaround for this would be appreciated.

Not sure, whether you're posting this as a question or an observation :slight_smile:

If it's a question, then the answer is no. Scripting functions are evaluated from the inmost to the outmost, so the when $regexp($2,\s+,.) is evaluated, $2 doesn't have any content yet.

Both really.

Technically it does when $2 returns a string?

I'm confused.

$2 is a returned string in my case, then $regexp('This String',\s+String,) works.

I know you say:

:raising_hand_man:t3: So, no way to work around this? A new fn to exposed the capture as a string perhaps?

Maybe I could work backwards and replace any \s with . but I feel I may run into the same issue.

Maybe I'm misunderstanding you here: $2 is replaced by the contents of the 2nd match group only at the time when the outer $regexp is evaluated. So, sure — it "returns" a string, but at the time the inner $regexp is evaluated, it doesn't contain what you're assuming it to contain.

Hopefully less confused now :smiley:

I'm not confused any more. Perhaps your opinion on a fn to convert captures as strings or something along that nature.

Possible future fn?

No, most likely I won't add a dedicated function for that. It'd break the clear flow of data and make a already complicated feature even more complicated.

No problem. There might be a way to change the string with lookarounds after the fact. Lookarounds aren't that straightforward but I'm sure there's a way.

Another idea would be to replace the spaces in an outer regexp and move the rest to the inner one.