Sure, in a simple scenario instr is probably a preferable solution (simpler, faster, lightweight, builtin).
However Regular Expressions are a very powerful tool that allow us to do a LOT more than simply finding the position of a character. Given Swi's very specific request for a regexp solution I suspect that simply looking for @ is not the ultimate goal, even if that goal is as simple as learning about regexps (as I rather suspect that they are familiar with Instr and would already be using it if it were appropriate)
Is regexp any faster or slower than using instr.
I'm talking about say finding every occurrence of a 3 digit number (Eg. 385) in a 10k text string (CSV version of an Excel spreadsheet).
Alternatively how would this compare timewise with updating a database table from the data and using a SQL query?
The only reason I want to use a regular expression in this case is because I am locked down in an application that I can only enter a regular expression into.
Does anyone know if there is a way to have a regular expression evaluate only if there is text to evaluate?
Meaning, the application I am using this in is causing an error because no text has been entered.
So in other words, in the regular expression can I conditionally evaluate based on whether or text has been entered?
I have the following regular expression for a phone#.
^\({1}[2-9]\d{2}\){1}\s?\d{3}\-\d{4}
I would like to add something to where an empty string is acceptable as input.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.