Click here to Skip to main content
15,567,466 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Regex syntax zoo Pin
YahiaEQ27-Dec-21 21:11
YahiaEQ27-Dec-21 21:11 
GeneralRe: Regex syntax zoo Pin
honey the codewitch27-Dec-21 22:20
mvahoney the codewitch27-Dec-21 22:20 
GeneralRe: Regex syntax zoo Pin
Cpichols28-Dec-21 2:29
Cpichols28-Dec-21 2:29 
AnswerRe: Regex syntax zoo Pin
Bruce Patin28-Dec-21 7:01
Bruce Patin28-Dec-21 7:01 
GeneralRe: Regex syntax zoo Pin
honey the codewitch28-Dec-21 8:01
mvahoney the codewitch28-Dec-21 8:01 
AnswerRe: Regex syntax zoo Pin
David On Life28-Dec-21 18:42
David On Life28-Dec-21 18:42 
GeneralRe: Regex syntax zoo Pin
honey the codewitch29-Dec-21 1:14
mvahoney the codewitch29-Dec-21 1:14 
GeneralRe: Regex syntax zoo Pin
David On Life31-Dec-21 7:11
David On Life31-Dec-21 7:11 
Thanks. Did you mean that I should replace the .NET RegEx with a 3rd party (DFA based) RegEx, or that I should have people use DFAs instead of RegEx?

Backtracking's not really an issue. Most of the time I'm just looking for one of the following:
  1. String Contains Pattern (e.g., "Pattern")
  2. String Contains Pattern A or Pattern B or ... (e.g., "PatternA|PatternB|...")
  3. String Starts with Pattern (e.g., "^Pattern") or Ends with Pattern (e.g., "Pattern$")
  4. String Exactly matches Pattern (e.g., "^Pattern$")
Sometimes I use more complex options:
  1. String Contains Pattern A or Pattern B (e.g., "Pattern(A|B)")
  2. String Matches product code (e.g., "P\d+(-\d+)?")
And the ones that RegEx doesn't support:
  1. String doesn't match one of the above (implemented by me as "!...")
  2. Numeric or Date comparison (implemented by me as "<10" or ">=1/1/2000" ...)
  3. Within range (currently not implemented except via regex starts with).
That's about as complex as it gets.

The main performance issue is that I'm using it for ad hoc live filtering of up to 3-4,000 records (filter changes as every character is typed) with the potential for filters on multiple fields, and I'm trying to keep it responsive (< 2 seconds worst case, preferably < 1/10 second).

So far, the performance is reasonable, if not ideal (using the native .NET REGEX), so I've not been highly motivated to change. A 3rd party drop in engine might work (my thoughts were more along the line of recognizing the simple cases and hard coding them, it's hard to beat string.IndexOf and other string intrinsics which can easily handle three of the first four cases.

I also use RegEx's for backend filtering (before it gets to the UI) and there I'm limited to what the database engine supports. Performance is generally pretty good; however, I wonder if there would be value in my detecting simple cases up front and converting them to different operations before sending to the backend. For example:
  • Instead of 'Field matches regex "Pattern"' generate 'Field contains "Pattern"'.
  • Instead of 'Field matches regex "^Pattern$"' generate 'Field == "Pattern"'.
These patterns are also typically entered by users, but not live (they have to 'submit' the query). I already do some simple pattern manipulation, mostly adding a (?i) to the front as the engine is case sensitive by default and I'd rather it not be. This would be a bit more complex as I'd have to manipulate the operation, not just the pattern.
GeneralRe: Regex syntax zoo Pin
honey the codewitch31-Dec-21 7:52
mvahoney the codewitch31-Dec-21 7:52 
GeneralRe: Regex syntax zoo Pin
David On Life31-Dec-21 21:24
David On Life31-Dec-21 21:24 
GeneralRe: Regex syntax zoo Pin
honey the codewitch31-Dec-21 22:23
mvahoney the codewitch31-Dec-21 22:23 
AnswerRe: Regex syntax zoo Pin
jschell29-Dec-21 8:57
jschell29-Dec-21 8:57 
GeneralRe: Regex syntax zoo Pin
honey the codewitch29-Dec-21 10:42
mvahoney the codewitch29-Dec-21 10:42 
JokeFirst image from James Webb Telescope Pin
Jacquers26-Dec-21 20:10
Jacquers26-Dec-21 20:10 
JokeRe: First image from James Webb Telescope Pin
oofalladeez34327-Dec-21 9:21
professionaloofalladeez34327-Dec-21 9:21 
GeneralRe: First image from James Webb Telescope Pin
Mark Miller28-Dec-21 5:31
Mark Miller28-Dec-21 5:31 
QuestionSaving URLs For Later reading? Pin
raddevus26-Dec-21 10:35
mvaraddevus26-Dec-21 10:35 
AnswerRe: Saving URLs For Later reading? Pin
Mircea Neacsu26-Dec-21 10:40
Mircea Neacsu26-Dec-21 10:40 
GeneralRe: Saving URLs For Later reading? Pin
raddevus26-Dec-21 10:46
mvaraddevus26-Dec-21 10:46 
GeneralRe: Saving URLs For Later reading? Pin
Mircea Neacsu26-Dec-21 10:51
Mircea Neacsu26-Dec-21 10:51 
GeneralRe: Saving URLs For Later reading? Pin
David O'Neil26-Dec-21 11:22
professionalDavid O'Neil26-Dec-21 11:22 
GeneralRe: Saving URLs For Later reading? Pin
raddevus26-Dec-21 11:26
mvaraddevus26-Dec-21 11:26 
AnswerRe: Saving URLs For Later reading? Pin
Ron Anders26-Dec-21 10:55
Ron Anders26-Dec-21 10:55 
GeneralRe: Saving URLs For Later reading? Pin
raddevus26-Dec-21 11:24
mvaraddevus26-Dec-21 11:24 
AnswerRe: Saving URLs For Later reading? Pin
David O'Neil26-Dec-21 11:22
professionalDavid O'Neil26-Dec-21 11:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Would you use ChatGPT to do your work?
We're just talking about whether you would, not whether you should.
  Results   94 votes