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.

learn more… | top users | synonyms

3
votes
0answers
13 views

Regular Expression to Remove Comments

This was developed in response to a question on Stack Overflow, Removing comments using regex. What the OP needed was a regular expression to use in C# to remove comnents from lines of a file. All ...
2
votes
1answer
42 views

python recursive regex optimization

I parse a big source code directory (100k files). I traverse every line in every file and look for function calls via regex matching. I know that using regex to parse languages is a terrible idea. ...
0
votes
0answers
39 views

Find every two vowels inbetween a consonant [on hold]

Task You are given a string . It consists of alphanumeric characters, spaces and symbols(+,-). Your task is to find all the substrings of that contains or more vowels. Also, these ...
2
votes
1answer
46 views

JavaScript Website-Content Grabber

I my firm a few people have following problem: A Content Management System is hosted externally. The treaty doesn't include database-access. In September the treaty will expire. So they have to get ...
3
votes
1answer
41 views

Retrieve a number in a webpage and store in a SQLite3 db

I'm beggining Python. So I wrote a program which is supposed to get a number of connected people on a forum (like this one : http://www.jeuxvideo.com/forums/0-51-0-1-0-1-0-blabla-18-25-ans.htm) and ...
5
votes
1answer
80 views

Wrap string at certain delimiters

The method receives an unformatted string and it needs to put line breaks after ';' or before 'i)' and 'i.', where i - integer. If received a string like '; 1)', then it should add only one line ...
2
votes
1answer
49 views

Number of capture groups in a regular expression in php

I am trying to find the number of capture groups for a regular expression using this PHP function. ...
1
vote
1answer
25 views

Regex to DFA parser in Dart

I've created a Regex to DFA parser, using Thompson's construction algorithm and epsilon-reduction. Here is the code: builtins.dart: ...
3
votes
2answers
739 views

Convert Persian and Arabic digits to English

I use the following utility method to convert Persian and Arabic digits to English using regex: ...
2
votes
1answer
37 views

Pattern matching (like regex)

This is a much more basic implementation of Regular Expressions (Python docs). Do note that core functionality is missing and the functions aren't completely fool-proof, but it does a good job of ...
1
vote
0answers
20 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
36 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 ...
3
votes
2answers
485 views

Cleaning up an utterance using multiple regex substitutions

I need to use regex for some stuff (mentioned in code comments) and wrote the following code, which works perfectly fine for my need, but I wanted to know if there was a way to improve this code? Am ...
4
votes
2answers
51 views

Convert strings from OW format to ADE format using many regex replacements

I have a working C# (version 5) function that I use to match an input string to one of many unique regular expression patterns and return the replacement string associated with the matched pattern (...
6
votes
1answer
145 views

Basic JavaScript template engine using replace, match and RegExp

To practice with regular expressions, I wrote this basic template engine in JavaScript in addition to a simple test case to make sure it works correctly. I am wondering if there is any improvements I ...
3
votes
2answers
39 views

Parsing very simple CSS into selector and declarations (as as single piece)

The last part of my HTML genrator requries a few styles. Because all styles are inline and the styling is for emails there won't be any fancy selectors, just by element, id or class. The most ...
2
votes
0answers
43 views

Determine HTML formatting from simple HTML template

My HTML framework needs to do one more thing. Its renderer can format the output so it needs to know the formatting rules. In the first version I used a hardcoded dictionary that looks like this: <...
6
votes
1answer
48 views

My second requests script for a wargame

This is a addition to my previous question earlier today. I've taken the suggested changes into account and have written a solution to Natas7, a problem that requires some more 'meat' on what I'd ...
-1
votes
1answer
26 views

Regular expression check for different kinds of fields [closed]

I have a list of items where I want to check each and every item of array that it matches regular expression or not . Every field have different regex example accountNumber will have different regex ...
0
votes
1answer
36 views

Converting Confluence markup to a simpler XML format

I have a code that converts one xml structure to another. I am removing unnecessary tags and replacing some temporarily. I think I have way too many replace operations and wondering if there is a way ...
6
votes
4answers
249 views

Count patterns that start and end with “1”, with 0's in between

A string contains many patterns of the form 1(0+)1 where (0+) represents any non-empty consecutive sequence of 0's. The patterns are allowed to overlap. For example, consider string "1101001", we can ...
2
votes
1answer
71 views

Count regex in file

I have a task to search regex in many files. How do you think is this code optimal by performance and complexity? ...
7
votes
1answer
56 views

A simple regex based lexer

Recently I've been interested in language design and text processing. And a common program needed in both of those fields is a lexer. And since I found myself writing a new, slightly different lexer ...
1
vote
1answer
20 views

Python script to identify regex matches in all subdirs and write dict of matches to MongoDB

I've been attempting to teach myself Python over the past couple of months and have been setting myself practical challenges to learn different aspects of the language. I have a deep structure of ...
5
votes
1answer
89 views

Finding the first non-repeated character in a string

Given a string, find the first non-repeated character in it. E.g. "yellow" should return "y" There are several solutions for this in other languages but I haven't seen one written in Perl. My main ...
7
votes
2answers
441 views

Using python and beautifulsoup to iterate through a list of websites to find a particular string

I'm attempting to find companies who mention a particular service in on their homepage. To do this, I am iterating through a csv file with two columns - ID and URL. I'm using BeautifulSoup to get the ...
9
votes
0answers
162 views

Using lots of regex substitutions to tokenize text

I authored a piece of code that was merged into the nltk codebase. It is full of regex substitutions: ...
3
votes
2answers
63 views

Extracting an IP address from a hosts file by hostname

I am currently working with Vagrant for the first time, and therefore also working with Ruby for the first time. I have a specific hostname and IP address I would like set for my VM, both of which are ...
3
votes
1answer
73 views

Return a substring containing a certain pattern to VBA

I've written in a C++ dll the following function to return to VBA a substring containing a certain pattern, given an input string, which contains that substring: ...
2
votes
1answer
78 views

Read/Write a TXT file with timestamp

I have write this code that read a txt file and re-write it whith the timestamp sorted. This is the result (top image is input, bottom is output) MY QUESTION IS: Anyone do you have a suggestion to ...
1
vote
1answer
72 views

Serve folder content using PHP route (SSI) (dynamic includes)

I have just written a PHP router, but I have some security concerns about this function. I am trying to serve all the content of a folder using this function. I am trying to prevent harmful URLs. <...
4
votes
1answer
33 views

Try every option for a command and make anagrams out of the successful ones

What I have: I am trying to find what words you can make out of Linux command options like ls -cat or ps -elf. To do that I am ...
3
votes
1answer
64 views

Compress svg files in PHP

I wrote something to "compress" svg files. The svg files I am using often have comments and empty <g> tags, and I want to remove them. My main goal is not the ...
2
votes
2answers
79 views

Get a number from a class of a HTML element

I've got an element with multiple classes in a page and I need to dynamically get the number at the end of a specific class name. Example: ...
2
votes
2answers
91 views

Console application to search for files that contain a match for a regex

I created a small console application to recursively search a folder and all subfolders for files that contain a match for a regex. The command line arguments are the path you're looking to search ...
1
vote
2answers
100 views

Display random facts about cities

This is one of the first scripts I've written. I set it aside for a month or so and I'm not sure how to go about refactoring it. I'd love to have it be more OOD, but I have much more studying before ...
3
votes
1answer
80 views

Helper functions to perform simple token replacements in a string

This script provides function T9r, which has some methods to detect, parse and replace tokens "{{ some_token }}" in a string with properties on an object. My use case, to have "composable" json ...
3
votes
1answer
45 views

regular expression for telephone/mobile per country and variable naming

would like to know if there is a better approach in doing a telephone/mobile number regular expression for specific country. this includes naming variables like how to know if format is international ...
0
votes
0answers
33 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. ...
3
votes
1answer
82 views

Regex to check IP address in Java

I'm toying with Regexes to parse IP Addresses. I've got it to test for anything over 255: ...
-1
votes
1answer
55 views

Javascript to PHP email validation? [closed]

So I'm working on an application where Javascript will first validate the email using a regex and then once sent to PHP, PHP will verify the user did not modify any of the javascript and validate the ...
4
votes
2answers
107 views

Matching a time interval using regex

What I needed to do was check whether a given string matches a certain pattern. The pattern is this: 00:00:00,000 --> 00:00:00,000 Things to keep in mind: ...
3
votes
1answer
55 views

Parsing HTML to download e-books

I'm currently writing a little tool to get into Go. As I'm not familiar with the language I'm especially looking for Conventional go stuff. utility.go feels wrong.Should I wrap the client and email/...
2
votes
2answers
51 views

Extract title with regex

I'm quite new to Go and I feel like this code could be smaller and cleaner. I would love any suggestions and/or hints about mistakes and conventional go things! ...
0
votes
2answers
52 views

Matching whitespace and non-whitespace characters with RegEx

I just started watching some regex tutorials on Plural Sight just to learn how to write a proper regex expression. So far so good, it's been alright and I decided to test my knowledge on Hackerrank. ...
4
votes
1answer
58 views

PHP Regex Input Sanitization

This helper class is supposed to validate the user input from a text based wifi login form. The entire process is basically this: I use the create_voucher ...
2
votes
1answer
60 views

Replace fixed width values over 530px with 100% using RegEx

Our site sends users transactional html emails. That content is then stored in a DB for retrieval when the user visits the mailbox section of our site. The emails which get sent contain media queries ...
2
votes
2answers
54 views

Filtering a data structure using regex predicates

Assume we have a data-structure like this: ...
4
votes
1answer
59 views

Remove specific CSS rules from WYSIWYG text

I have created a working function for cleaning some specific styles within the text from a WYSIWYG editor. ...
9
votes
1answer
104 views

Beginner code for MadLibs game

I am working through Automate the Boring Stuff. How can I make this code cleaner/better? ...