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
0answers
19 views
Hex Color Analyzer in javafx
Here is a simple hex color fetcher and analyzer in javafx that i wrote to understand multi-threading in javafx.
Questions:
Is my regex ok ? or if it can be improve?
I am not much familiar with ...
1
vote
0answers
46 views
Match the maximum consective count of `)` followed by a keyword
I am applying a regular expression to match and keyword that is followed by maximum number of closing parenthesis. Code is done in python using ...
5
votes
1answer
39 views
Perl script to match case law references
I am very new to Perl and decided to work on a simple script that could solve a problem I encounter in my day to day work. The purpose of the code that follows is to search over a body of text and ...
0
votes
0answers
23 views
Link Detection and Addition of Anchor
I have the following code but I am not too happy about the way I replace e-mails with mailto links. Additionally, I am thinking how to conbine the logic of the URLs and E-mails into one Loop.
...
3
votes
1answer
71 views
Python code to do regex search and saving results to csv
I am a Python beginner, and I wrote a simple Python program, which does the following:
search the pattern in the lines of a file (contains messages)
pick the information from the lines and save it to ...
3
votes
0answers
37 views
Decode HTML Entities in VBA using regex and dictionary
I receive HTML-encoded text that includes named and numbered entities, and I need the decoded HTML.
There were just too many bad solutions for this online.
I use regex pattern ...
-4
votes
2answers
57 views
Given a blob of text (that is a complete html page) return all email(s) present [closed]
Okay so this is NOT my code, I just inherited it. Seems it has an obvious bug that it will only return the first email despite being called "GetEmails". My main concern is actually that it takes ...
5
votes
4answers
598 views
Check if a file path matches any of the patterns in a blacklist
I'm processing a list of files, and want to check the filenames against a list of regex, like:
...
4
votes
0answers
44 views
Counting instances of a string in a binary / unicode file using regex
(Originally posted on Stack Overflow)
I need to run through a number of bespoke files (I'm unsure if they are unicode / ascii or binary so have attached a snapshot through notepad++). I'd like to ...
6
votes
2answers
115 views
Performing a procedure for each form edit
I am a bit new to programming. I have some edits on my form, and for each edit completed it will have to do a procedure.
Currently, I use this code that works perfectly, but I am looking for a better ...
0
votes
1answer
68 views
Extract regex matches with non matching parts
I want to check a string by using multiple search patterns and split the string at every occurrence. I'm using RegEx and it works fine. But I'm worrying about efficiency and performance.
...
1
vote
0answers
23 views
Matching URIs with regexes for Apache CXF InInterceptor
In my project I need to compare the URI with 15+ regex patterns. Currently I have used a if ladder to execute the appropriate code if any of them gets matched.
...
3
votes
0answers
29 views
Formatting XML strings in JavaScript for readability
I've created a vanilla JS function to indent XML strings so they can be more easily read. It uses some pretty nasty regex...yes, I know it's a cardinal sin for XML/HTML, but it works. For instance, ...
3
votes
2answers
28 views
Parsing and extracting all IDs from a document (using regex with capture)
I'm interested in parsing and extracting the IDs found in a document. The IDs are found throughout the document in the this format:
IDStart=1FG3392MQ9&IDEnd
The "1FG3392MQ9" is an example of ...
1
vote
0answers
44 views
0
votes
1answer
58 views
php preg_replace kills cpu
I am reading some HTML files and returning them upon request, but when they go through my codes I need to filter out some stuff from these HTMLs, everything is working fine and I'm using about 20 or ...
4
votes
3answers
88 views
Replacing a string until it matches a certain length
I'm trying to make an SMS Shortner for a kata at Codewars:
Your task is to shorten the message to 160 characters, starting from end, by replacing spaces with camelCase, as much as necessary.
I've ...
2
votes
0answers
59 views
4
votes
1answer
51 views
Average calculator with filters
I am a beginner in Java and I have a hobby project to create a tool for statistical calculations.
Users can upload csv with results of a survey. The responses stored in a ...
3
votes
1answer
96 views
Regex for domain validation name validation
I created this regex in Javascript that returns a boolean for Domain validation that meets the criteria to allow IP addresses and ascii domain name. The assumption is that the TLD should be atleast ...
3
votes
2answers
155 views
Check if a string contains a set of characters
I have written this piece of code to check if a string contains a set of characters, regardless of the order.
Eg: 'ruby is best' / 'bysbe' => true
Code:
...
6
votes
1answer
44 views
Extracting Linux configuration information using Bash and Perl
For few days I'm thinking about making my code faster and using less CPU. This code is a statusbar that runs in a loop. I'm asking because there's a lot of perl and I'm wondering if it could be done ...
2
votes
2answers
55 views
Transform snake_case to camelCase with sed
I want to convert my_long_variable to myLongVariable in sed.
This works:
...
1
vote
2answers
54 views
Phone number/email regex verifier
Is there anything I can do better here? I tried looking for ways to simplify this with comprehension but could not figure out how and was told it is better to explicitly use ...
1
vote
1answer
107 views
Pokemon search engine
I am making a simple function to find and match any possibilities what Pokémon the user wants. This is accomplished by taking in the input (what the user thinks the Pokémon is named) and compare its ...
9
votes
4answers
2k views
Regex to enforce password requirements
I'm trying to write regex to validate the password for the given rule.
Passwords must be at least 8 characters in length and contain at least 3 of the following 4 types of characters:
lower case ...
3
votes
2answers
45 views
Capturing the positions of “start” and “end” markers in a multi-line string
Is there any better (and shorter) way to get index of a regex match in Python?
...
12
votes
2answers
108 views
Fighting f̶i̶r̶e̶ regex with f̶i̶r̶e̶ regex
So someone requested a Regex Builder / Assistant for Rubberduck and since my CS class had been covering the topic only recently I was thinking to myself: "This sounds interesting, you should do this".
...
12
votes
2answers
467 views
Regex Matching a Naming Convention
Program Purpose
So, I have a naming convention for certain folders.
I want to take in a folder name, and determine if it conforms to the convention.
Naming Convention
The convention (case ...
1
vote
0answers
125 views
SSRS: code function to sanitise HTML for rendering in RDLC report
Background
I have an RDLC that among other things displays text coming in that is captured in SharePoint, using a custom control (TinyMCE) that exposes limited formatting options to users.
The SSRS ...
1
vote
1answer
81 views
Password validator using regular expressions
I wanted to learn some regex, but learning regex is super boring so I decided to write a password validator that will validate a password with regular expressions.
How it works:
You enter a password ...
5
votes
1answer
35 views
Improving CSV filtering with Python using regex
Consider a .csv file that contains a set of video names like so:
...
8
votes
3answers
995 views
Word-counting script in C#
My goal is to read from standard input, break up the input into words (Unicode letters and apostrophes), case-insensitively, and produce a report to standard output, where each line is a word followed ...
3
votes
0answers
33 views
Convert accented character to user name
I am using below function for converting the accented character to user name.
...
7
votes
1answer
118 views
Parse regular expression
Task:
This function searches given null terminated string pStr by given subset of
regular expression pMatch.
Return value is ...
7
votes
1answer
43 views
Python App that parses file for lines that match a format
I recently wrote some code that was dinged on not having well defined tests and poor modularity. Was hoping someone could review my code and give me pointers on how to create more well-defined tests (...
2
votes
1answer
38 views
Derived Class to keep track of “original strings” in std::regex and ease out their usage while coding
We all know that std::regex class doesn't allow access to the original string which was used as the source expression. (In fact, GCC even keeps the original string as ...
3
votes
2answers
64 views
Optimize a simple and quick python script for transposing a .csv file
I need to transpose the following file output1.csv, which is is a result from a quantum chemistry calculation into a single colum efficiently:
...
7
votes
0answers
60 views
Regex-guided crawler that downloads regex-matching images up to a crawling level
This is one simple crawler that downloads images from websites, the website's URL to be crawled to must match the regex, as well as any image-to-download's URL.
(Also, I know, I made my own thread ...
7
votes
3answers
173 views
Test if a string is a palindrome
I got this out of an article on interviews / code challenges. The challenge text goes like this:
A palindrome is a word, phrase, number, or other sequence of
characters which reads the same ...
5
votes
2answers
84 views
Basic arithmetic calculator in JavaScript
Task is basically:
"Write a function which takes two number as the first two parameter. The third parameter is one of the arithmetic operators (+ , - , * , /). Execute the arithmetic operation (...
4
votes
2answers
25 views
Isolate URLs from other text around it and put each on own line (with sed)
I have a small shell script that uses sed to take an input file of URLs with hand-written notes around them and strips the notes and puts each URL on its own line. ...
1
vote
1answer
102 views
Moving MP3 files from one directory to another using regex
This is a simple script for moving my MP3 files from one directory to another. I'd like to know if there is a more efficient way to handle my task in the script. I analyzed the algorithm to be \$O(n^2)...
3
votes
1answer
79 views
Regex Tool in PHP
I'm looking for feedback about anything and everything to do with this short program. For example, is there a risk in not sanitising the data, and if so, how would I do that given the need for non-...
0
votes
1answer
11 views
Loading a file in vim via piped output of ag
I feel as if my scenario is fairly simple but that I might be overcomplicating it.
I am searching through files looking for a special condition, that is where the method ...
1
vote
0answers
26 views
Formatting a CHANGES text file as HTML
I have a function which is used to convert text (a CHANGES file) into HTML for reading. The function is essentially line-based: if the line is of this type, do this thing; if some other type, do that ...
3
votes
2answers
66 views
Validating multiple parameters by regex and length
I have a set of validation functions which return a response code along with an error message if the validation fails. Requests can be of three types, and each of them contains a different type of ...
3
votes
1answer
111 views
3
votes
1answer
59 views
PHP class which preserves line break by splitting the line into as many line break as it have
Can anyone here please review my PHP code which preserves line break by splitting the line into as many line break as it have?
...
0
votes
1answer
19 views
Find the number surrounded by square braces using regex
I need to remove all the numbers appearing inside square braces such as [9] , [2] , ....
This is my regex:
"(?:\[\d*\])"
Which is working fine.
But I am totally ...