Can I input an invalid string into a variable?

I don’t think it’s a good idea to try to help your users like this. If you don’t require the user to specify whether the input is interpreted as a regular string, a “raw” string or a regex, how will you know what they intend? Maybe they didn’t want regex search, but actually want to find the sequence of characters ‘Part_\d{4}’.

If the users are writing Julia code, and are supposed to supply regexes, it is better to tell them to actually create a regex (it is really super easy and useful) rather than secretly turning their input into a regex behind their backs. By trying to make it easy for them, you might instead make things inscrutable and confusing, and even make some things impossible to do.

6 Likes