I recently learned regex exists and it worked when I used \[.+\] at this website: https://regex101.com/ I copy pasted that expression in gdscript and I get: Parse error: Invalid escape sequence

Below is what I have.

	var regex = RegEx.new()
	regex.compile("\[.+\]")  # Parse error here
	var result = regex.search(ropePrint)
	if result:
		print(result.get_string())

You have to "double escape", since the backslashes are special characters in quoted strings: regex.compile("\\[.+\\]")

Welcome to the confusing world of regular expressions. :tongue:

It should look like this:

regex.compile("\\[.+\\]")

The \ needed to be twice because it has special meaning.

I thought of that, I thought I remember trying that, and I guess I didn't, or I screwed it up. Whatever the case, it's a sign I need to take a few days off.

10 months later