Skip to main content

Questions tagged [regular-expressions]

According to Wikipedia, a regular expression (abbreviated regex or regexp) is a sequence of characters that forms a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. "find and replace"-like operations.

1vote
4answers
216views

Programming language independent semantic validation of message protocol

I have a proprietary protocol that describes the exchange of messages of two participants (applications) via a messaging broker (mqtt). A participant is of type A or B. Each type is allowed to send ...
olimtrail's user avatar
12votes
2answers
2kviews

Designing a Python string validation library

My employer has a significant number of company-internal strings which require format validation. For instance, order number AAA-BBB-CCC, stock number AB-123456 or factory ABC1 - Regex with extras (...
MikeFoxtrot's user avatar
1vote
1answer
722views

How to implement a RegEx library in C [closed]

Background I have been attempting to create a line editor in C, eventually becoming a visual editor, and as a means of both allowing the editor to be useful but also learn more about C development, I ...
greybrunix's user avatar
31votes
6answers
12kviews

Is exposing regex in error response to end user bad practice?

Say I have a have request payload PUT /user { email: "invalid" ... } In the backend there is a email regex, which I cannot modify. Currently the behavior is to output: { "error&...
夢のの夢's user avatar
2votes
2answers
5kviews

Alternative to using regex in Python

Background I do programming with Python and now and then i run into a situation where i have to use regex Typically i try to learn a bit about it and look at examples of doing things similar to what i'...
sunyata's user avatar
0votes
0answers
172views

Domain specific language for regex processing

I am working on a DSL for text processing. The core is searching for regular expressions with some operators around them. These searches are embedded into a more procedural program, which allows for ...
flowit's user avatar
-5votes
1answer
1kviews

In what programming language is Python's regex module written in? [closed]

If I try to rewrite specific regex functionalities (e.g. substituting a string) in Python, a solution using the regex module is always faster. Is regex written in C?
gython's user avatar
3votes
3answers
3kviews

What is the right algorithm to match regex on a stream?

I'd like to match a regex pattern on a stream, but I am not sure what algorithm to use. I certainly don't want to load the entire file into memory. I tried to figure out how to do this, but I have ...
inf3rno's user avatar
  • 1,259
-4votes
1answer
3kviews

What is the best use case of a regular expression (TripleByte question)?

I have lots of experience with regexes. I just want to make sense of this. Am I missing something here. Which one of these would you rather validate with a regex? Question reads, Which of the ...
Evan Carroll's user avatar
0votes
1answer
49views

portable hashable string representation of data object

I have a class of (flat) objects that are going to be passed around between three different parties, each possibly running a different software stack. my_object: item: "string_a" money: ...
ShapeOfMatter's user avatar
1vote
1answer
286views

Is it possible to create a regular language from an non regular language?

I am wondering if it is possible to create a regular language from a irregular language if we add or remove finite number of words from it? say L is irregular, can we add or remove finite number of ...
mathnoobie's user avatar
2votes
4answers
3kviews

What is the optimal way to perform 5000 unique string replace functions in terms of performance?

Restructuring some code, and the way I built it up over time has portions that look something like this: s.replace("ABW"," Aruba "); s.replace("AFG"," Afghanistan "); s.replace("AGO"," Angola "); s....
Anon's user avatar
  • 3,633
1vote
1answer
4kviews

Is it a good practice to include empty/white space checks in RegEx?

The goal of the RegEx is to match exactly 6 characters, but in addition it should match empty strings or white space (e.g: ^$|\s|^(\w){6}$). Is it good practice check for empty string/white space in a ...
fortune's user avatar
3votes
1answer
194views

Why are `]` and `}` not metacharacters in Regex when ')' is?

In Regular Expressions Quick Start, it reads Twelve characters have special meanings in regular expressions: the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or ...
Wizard's user avatar
9votes
4answers
482views

Guarding user input of regular expressions against attacks

I am aware of Regular Expression Denial of Service (ReDoS). Is there any reasonable way to allow users to create custom regexes while guaranteeing that they don't submit an exponentially slow pattern?
icirellik's user avatar

153050per page
close