Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [regex]

Regular expressions are a declarative language, mainly used for pattern matching within strings. Please include a tag specifying the programming language you are using, together with this tag.

3
votes
2answers
88 views

Regex Generator in C++

So I am writing an XML parser, and I'm using regexes to do some pattern matching during parsing. However, writing longer regexes quickly became a bit boring, annoying and just confusing. So I thought ...
3
votes
0answers
68 views

Given an input string and a pattern, implement wildcard pattern matching

I have been trying to solve "Wildcard Matching" on leetcode. I know there are more "manual" ways to solve this without using the RE library. But I would like to know if passing the time limit is ...
0
votes
1answer
43 views

C# HTTP proxy performance

I'm implementing HTTP traffic monitor (proxy) for my project right now. It's performance is satisfactory. I've updated regex settings and improved performance but I think there are also ways to make ...
3
votes
2answers
81 views

Removing commented dead code without removing the legitimate comments

This question is the real question asked on StackOverflow. I'm here to review my answer and see how can I optimize it. Here is the answer text: This is a basic approach, but it proposes a proof of ...
2
votes
1answer
55 views

Looping through file finding sequences

For an assignment, I had to loop through a text file, and report any positions that a user entered sequence was found. Is there any way I can make this code more efficient, because it seems like I'm ...
5
votes
1answer
35 views

Regex character class range generator with certain characters excluded

While I was working on a personal project, I found I needed to exclude certain characters in a regex range. So I thought, why not implement a custom range exclusion check for greater efficiency, it'll ...
3
votes
2answers
71 views

Go grep command clone

I am trying to make a simple clone of the command line utility grep. I'm working on it just for fun and to practice Go. The thing is, I am trying to make it in a way that if several files are given at ...
4
votes
1answer
46 views

Converting Markdown to HTML using Go

I recently ported a blog of mine from Python to Go (to improve speed and performance) and while all is great so far, I'd like some help optimising the Markdown ...
3
votes
1answer
83 views

Processing a large list of strings

I am working on an application in C# WPF which reads a large file containing a number of HL7 formatted reports. My application takes in the file, reads and extracts any lines that starts with OBX and ...
1
vote
1answer
61 views

Multiple string replacement (with similarity) using a dictionary [closed]

I'm trying to replace a number of keywords with other corresponding values. I started with this method: ...
4
votes
2answers
61 views

Sanitize file or folder names to work with a legacy system

I'm in the unfortunate position to where I have to create files and folders programmatically that have to work with a legacy system. In this process, the file and folder names have to be heavily ...
4
votes
1answer
67 views

Replacing Uri with a more convenient class

I needed some data structure for holding Uris so I thought I try the Uri class. It quickly turned out that it's very impractical because: it's missing an implicit ...
0
votes
1answer
42 views

Custom indexOf for strings javascript with regex

I was wondering how efficient my code is creating custom indexOf for strings in JavaScript using regex instead of looping with a for statement the whole way in most ...
2
votes
1answer
39 views

Counting lower vs non-lowercase tokens for tokenized text with several conditions

Assuming that the text is tokenized with whitespace for a natural language processing task, the goal is to check the count of the words (regardless of casing) and check them through some conditions. ...
-1
votes
1answer
49 views

R Regex : Need only numeric figures [closed]

I'm working on R and using regex to keep only numeric figures in a column (I need to keep digits, negative and decimal sign). Suppose I've a value ...
5
votes
1answer
119 views

Strong Password Detection

I did the following Excercise from Automate the boring stuff with Python Chapter 7: Write a function that uses regular exppressions to make sure the password string it is passed is strong. A ...
6
votes
3answers
465 views

Compute count of unique words using ES6 sets

I have written a function which counts how many unique words are included in a given text. The source-code: ...
3
votes
2answers
65 views

Searching repositories for files with forbidden strings

I wrote a small tool for searching git repositories for forbidden strings that I don't want to commit publicly. It's still something basic but it does the job. The project contains three files. <...
6
votes
0answers
54 views

Minimal regex engine

A few months back, I posted a state machine for review. Thanks to the feedback, I was able to greatly simplify the implementation. I am posting the revised version, together with the Regex class which ...
1
vote
1answer
51 views

Replace characters using multiple dependent regular expression substitutions

I've written the following Python module to iterate over field values in the following two fields: "NAME_LABEL", "CATEGORY". I'm using regular expressions in the following function: "...
2
votes
1answer
44 views

Check values in datatables, with validation rules that vary according to the data source

Background I receive dataframes from several sources (below I call these sources s1, s2 and ...
0
votes
1answer
70 views

IsValidEmailAddress

I have created this function for Delphi 10.1 Berlin to validate an email address entered by the user: ...
2
votes
2answers
106 views

Validate Email as User is typing (JavaScript)

I have the following javascript function validateEmail(value). The goal of the function is to validate the users inputted email as they are typing. So if someone puts nfg@*gmail.com the email will be ...
10
votes
3answers
2k views

Imgur URL parser

Fairly new to Python, and I have been doing a few Edabit challenges, to better help with my problem-solving. I have just completed a some what semi-difficult challenge, and I was hoping for some feed ...
5
votes
1answer
677 views

Find the minimum number of characters to add to make password strong

This is the criteria: Its length is at least 6. It contains at least one digit. It contains at least one lowercase English character. It contains at least one uppercase English character. It contains ...
-1
votes
1answer
72 views

Decoding a string encoded by Caesar Cipher and some delimiters [closed]

I have the following code which I seek to optimize. The result of the bruteforce I already have but I'm just trying to learn some more python using the same example. The code in the data needs to be ...
-1
votes
1answer
93 views

Java Pattern search with variable string in pattern [closed]

Is there any better and compact way to write this code: ...
-1
votes
1answer
367 views

changing root password with an ansible playbook

It is with great difficulty that I resolved to solve my problem, so I allow myself to submit here the solution. I wanted a playbook that could replace on all hosts the root password with a string ...
7
votes
2answers
884 views

Find files by pattern and copy to target location

This is my solution to the Chapter 9 exercise in Automate the Boring Stuff: Selective Copy Write a program that walks through a folder tree and searches for files with a certain file extension ...
7
votes
3answers
502 views

Method for returning valid URLs from a sitemap URL

I need a method which fetches all of the text from a URL (generally a sitemap URL), and returns an IEnumerable of all valid URLs contained in the text returned from ...
6
votes
2answers
151 views

Finite state automata

This is a non-deterministic finite state automata (NFA) meant to be used with a Regex engine. To show some example usage, suppose you wanted to construct an NFA for the regex ...
4
votes
1answer
40 views

Enforcing numeric inputs and sanitizing different formats for IE11 input fields

I'm working on a web form that functions with numeric inputs. I have <input type="number"> input fields and with Chrome and Firefox things work nicely since ...
1
vote
1answer
73 views

Java Regex for Chess notations

I have this regex: (\d?)[A-Za-z](?=(\d?)(.*))(?=(.* ){5}) It would be used by me for Chess FEN strings. I wonder if regex ...
3
votes
1answer
79 views

Regular Expression for text that validates IPV4 or Hostname followed by a port number eg: 127.0.0.1:8080 or localhost:8080

An attempt with regular expression to do a foolproof validation of an IV4 or Hostname:port Number. Example texts that can be validated for any of the following: ...
4
votes
3answers
122 views

Reading a file line by line - Two tokens per entry

Problem Read a file and capture two tokens for every multi-line entry. First token is hexcode with which the entry starts. Second token is the remaining line(multi-line) of the entry. Trailing ...
1
vote
1answer
25 views

Rewriting domain only if not on local dev enviroment and forcing www with Mod Rewrite

I'm trying to write some mod rewrite code to redirect pages on a site to always use www and this has been working fine: ...
12
votes
5answers
3k views

Cleaning up date strings in Python

Working from a CSV of about 14.000 lines, I need to match dates in the CSV against some API. I'm reading the CSV using Pandas (for various other reasons). Most often, the date is just a year, i.e. an ...
2
votes
1answer
29 views

Finding incorrect yml headers

Introduction I am working on a semi large project with a few hundred files. In this project there is a series of lesson.yml files I want to check is formatted correctly. And, yes, every file I want ...
4
votes
2answers
97 views

Scan files and pick overlapped hex codes

Problem Two folders having files with nameEfile that store lines starting with hex codes. Print those hex codes that overlap in both folders. Solution ...
2
votes
2answers
48 views

Kotlin program to summarize git commits by regex match

I am trying to learn Kotlin. I am coming from some background in Java. As a learning exercise, I wrote this simple program to summarize occurrences of a string by author email in a list of git ...
4
votes
2answers
75 views

Assigning several variables from request URL using regexes

I refactored some of my code: Summary: This implementation works with PSGI/Plack. It gets the URL from $env->{PATH_INFO} and assigns a different variable ...
1
vote
2answers
72 views

Powershell function to search CSV logs for certain regexes

I have a parser that goes through two different logs, both .csv files, and checks for certain lines based off the regex code that I have chosen. This parser works fine, it just takes about a minute ...
1
vote
0answers
64 views

Determining if a regex can be found in a string

I've written my first C++ multithreaded application (as far as I can recall) which determines if a regex can be found in a string. This code works correct to the best of my knowledge. Could you gals/...
5
votes
2answers
68 views

Regex-based parsing of a specifier for dice

In this android app, the user can enter (a subset of) roll20 notation to roll that many dice. Inputs will look like "4d6" at the simplest, but the user can also add or subtract numbers, and drop or ...
2
votes
0answers
248 views

Regex search to Excel

I made this to track my variable changes while I experiment in Python. I tend to use the same variable names and fit different values to them so it's nice to be able to see what I've tried, especially ...
2
votes
3answers
170 views

Retrieve words from dictionary when they meet letter requirements

I have a set of functions that retrieve words from some arbitrary dictionary based on what letters they have. For example, this function gets words that use only the specified letters: ...
3
votes
1answer
29 views

Ruby Regex to update various variables inside a file

In our applications we have a version file that has three variables that are then joined to create a string that can be used for the semantic version. The file looks like: ...
5
votes
2answers
432 views

Searching for a word in a list of tuple extracted from a db via SQL

Python 3.6 and Sqlite3. I have a database with something like 300K entries, each entry has several fields (date, username, etc) and a "text" one. I have a list of 200 words and for each word i have ...
5
votes
2answers
222 views

Simple parser with regular expression

If I draw something in Illustrator and extract it with AI2Canvas I want it to be customizable so I wrote this simple program. It adds two variables: one to resize and one to shift the path coordinate. ...