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.

44 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
12
votes
0answers
247 views

“String Interpolation in {language}”, “VBA”

"This is {0} cool!", "freaking" I've always wanted an easy and intuitive way to inject variables into a string. So after about 10 variations, I finally came up with this function. How it works The ...
6
votes
0answers
721 views

Parsing Lua 5.2 strings with patterns

I wrote some code to parse Lua 5.2 strings in Lua 5.1, using patterns. It works perfectly as far as I tested. ...
5
votes
0answers
1k 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
0answers
126 views

VerbalExpressions in Scala

I forked the original implementation of VerbalExpressions in Scala here: https://github.com/pathikrit/ScalaVerbalExpressions I am looking forward to these things in the code review: ...
3
votes
0answers
39 views

Powershell: does a file name contain a value

I need to check if a filename contains a value that I get from 2 excel Columns (ContractNumber & PONumber). My Script is too slow right now. It has been running for 1 hour, and it completed only 2%...
3
votes
0answers
95 views

PL/pgSQL function to test if a word is contained within a phrase

I am using PostgreSQL 11.0 and I wrote a PL/pgSQL function to test if a word or phrase is contained within another phrase. This function is called several times within another function to extract some ...
3
votes
0answers
42 views

Generate CSV from multiple files on Regex Python Output

I have written a python script using regex to extrapolate a poorly formatted text file data table into an actual data table. I am currently printing the output using . C:\my file location\file.csv in ...
3
votes
0answers
466 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 ...
3
votes
0answers
280 views

Scraper Class with Regex

I already posted a not (yet) complete version of this class, but that question got closed, because it contained not passing tests. Here is the full version, all 5 tests pass. Originally there was ...
3
votes
0answers
207 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 ...
3
votes
0answers
980 views

PHP routing system

I made a routing system for PHP inspired by Symfony's router composed of a few classes. First I am using Symfony's HTTP Foundations component. Then, I am emulating the classes in the routing ...
3
votes
0answers
383 views

Efficient JavaScript/jQuery typewriter effect that handles HTML5, entities, and text

How should this code be improved? For instance: How could it be shorter, clearer, deal with memory better, use a plugin/library, better prepared for web input? I can break up and clarify the regex or ...
3
votes
0answers
75 views

Scraping paths from a Gruntfile

As a part of my Tabv Vim plugin (which at this stage is nothing more than a pitiful rag-tag assortment of half-baked hacks), I have a function which attempts to guess the directory paths for main ...
3
votes
0answers
448 views

Rhino helper class to support ECMA-262 regular expressions

This is a sample class using Rhino (1.7R4). I need it because in the context of JSON Schema, regexes should be ECMA 262. One requirement is that it is thread safe, and it is. But I'm not sure I ...
2
votes
0answers
26 views

c++ regex helpers

I've created 2 helpers for std::regex. The first helper match fills the given ...
2
votes
0answers
76 views

Sanitize input for a “robot on a grid” kata

I have the following piece of code which is FSI tested and works. However, I want to trim it as much as possible (not only the comments, which are there for my own future reference) and make it as ...
2
votes
0answers
587 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
0answers
32 views

dyon vim syntax plugin

I recently made vim-dyon which is a syntax highlighter and indenter for the dyon programming language. There are probably some issues with being absolutely correct (since I am not too familiar with ...
2
votes
0answers
36 views

Multilang sentence to N-gram

Task: Transform sentence to n-gram and remove all punctuation Tests: Input: ngram('Name, + other ~ name!', 1) Result: ['Name', 'other', 'name'] Input: ngram('Name, + other ~ name!', 2) ...
2
votes
0answers
222 views

Convert python's strftime directives to user-friendly format examples

I'm converting python's very un user-friendly strftime date time directives to user-friendly formats so that users of an API will know how to format a date if they send an invalid format. My thinking ...
2
votes
0answers
471 views

Leetcode 10: Regular Expression Matching

Problem statement Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching ...
2
votes
0answers
348 views

C++ regex_replace with arbitrary function

This is a version of C++17 regex_replace that handles arbitrary functions to do the replacement, instead of using regex_replace'...
2
votes
0answers
56 views

Chromium based browser and Firefox omnibox: paste/type search keywords to go straight to google.com search results

Functions and features: paste/type search keywords to go straight to google.com search results pages - explicitly google.com NO google.TLD ...
2
votes
0answers
3k views

Regex credit card expiry date auto format

I'm trying to write a function that will get content from input element and try to format numbers entered in input box in MM/YY. Following is a solution that I have, and I want to reduce the number of ...
2
votes
0answers
49 views

Regex to find wildcard imports in Java

Could I get a review on the following regex: ^import[\s\S&&[^\*\n]]*?([\*]{1}\;\s*$) All the details: Years ago a colleague shared a useful little regex ...
2
votes
0answers
151 views

PHP tagging script

I have created this PHP script in Laravel. I have database table with items and in my app I can create tags with different regexes. If regex matches text in description or epoch. I will insert ...
2
votes
0answers
78 views

R data.frame iterrative search algorithm

I have the following data frame: ...
2
votes
0answers
2k views

Automatically redirect /index.php files to their URL directory with .htaccess

The requirements: Work inside .htaccess (preferably via mod_rewrite) Redirect requests from /any/directory/index.php to ...
1
vote
0answers
31 views

git status parser using regular expressions in javascript

I'm looking for improvements of a code that filter the output of git status --ignored and git status --ignored -bs commands. I ...
1
vote
0answers
66 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/...
1
vote
0answers
42 views

Trim real numbers to a set precision when the input is a string

The objective was to allow me to trim a real number to a set precision after the decimal if one exists but only if the value does not contain an exponent. My input is actually a ...
1
vote
0answers
65 views

Systematically reordering parts of street names and replacing abbreviations

I'm working on cleaning up the openstreetmap data, hope to make it more concise. The goal is to change the following street name in two parts: check to see if (S) is at the end of the name If yes, ...
1
vote
0answers
792 views

Finding a repeated pattern and doing something with the match

I have several implementations of finding a repeated pattern and acting on the matching input if it is found. So I want to find this ...
1
vote
0answers
68 views

python indexing-code optimization

I'm writing a plugin to a text editor that will perform indexing of large code bases. The indexer will retrieve all function calls for a certain function (much like the functionality of full featured ...
1
vote
0answers
838 views

Javascript email and phone validation regex

I'd like to get a review on 2 regexes, one for email and one for phone validation. ...
1
vote
0answers
1k views

C# Regex to match UTC dates

Made the following regex strings to match for typical UTC dates. I'd appreciate it if you guys can let me know if it seems fine and not too lengthy. ...
1
vote
0answers
69 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 ...
1
vote
0answers
55 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. ...
1
vote
0answers
138 views

Replacing mapply to gain speed

I have the following data frame: ...
1
vote
0answers
655 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
0answers
70 views

Regex to obtain float values from a large text file

I am reading a text file and obtaining certain data from the file. The following line is repeated over a million times in the file where the £ values may differ each time. Start Game, Credit: £200....
1
vote
0answers
846 views

HTML to plain text converter

Please, review the code below. Test class: ...
0
votes
0answers
41 views

How to filter URL from the array list based on the string name with regExp?

The solution found to filtering pathname with customising current normalizeTme() function. For sure it is not the ideal way of ...
0
votes
0answers
29 views

WordPress hook to add URL-rewriting rules for articles with language variants

Please look at this working WordPress code: ...