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.

Filter by
Sorted by
Tagged with
0
votes
0answers
26 views

function to check if anchor tags contain href attributes with 301

I made this function to test if the content has 301 redirections.. Please can you help me optimize it better because it's too slow ...
4
votes
3answers
244 views

use regex to separate a list of serial numbers into multiple lists with matched prefix

The question comes from How to separate a list of serial numbers into multiple lists with matched prefix? on Stack Overflow. Input: ...
1
vote
1answer
64 views

Class showing a format similar to var_dump v1.0.5

First of all I must thank for the help given in the previous post: Class showing a format similar to var_dump RC5 Version I have it deployed in a early versio v1.0.5: https://github.com/arcanisgk/BOH-...
2
votes
1answer
18 views

Validator and Sanitizer for HTML 5 attribute regex according to current HTML living standard

According to https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 an HTML 5 attribute name is defined like this: Attribute names must consist of one or more characters other than controls, ...
1
vote
1answer
146 views

Downloading and parsing research papers

I am trying to write a script which gets a research paper from a website by calling their API and then traverse it sentence-wise with some conditions. The paper is accessible in XML format. I am ...
-1
votes
2answers
63 views

Parse file and make output in custom List [closed]

I have a file output like this and want to do parsing and put the output into a List. The biggest problem here is the name of a wake-lock which appears after ID and runtime, in some cases, it contains ...
3
votes
5answers
177 views

A simplified regular expression matcher

I am working my way through some code challenges — partly to improve my problem solving, but also to improve my code quality. I think my current (fully-functional) solution to a challenge is pretty ...
3
votes
0answers
41 views

Request for help to speed up batch program for 17,000 TXT files

I have over 17,000 pages that have been scanned (for a local history archive) which I have OCRed using Tesseract to individual TXT files. I want to be able to search/locate every page containing a ...
2
votes
2answers
74 views

Replace string based on multiple rules, don't replace same section twice

Given a 2-column CSV dictionary file that contains translation of certain words, this c# code needs to replace the first occurrence of a word in the dictionary. Once a segment of string has been ...
2
votes
1answer
48 views

Optimizing a script that switches function arguments in code files

I made a quick script, that inputs file paths(made for C files), function names and 2 indexes. The script goes over all of the files and switches the indexes of the 2 functions. e.g.: Running the ...
8
votes
3answers
616 views

Function in Python to extract web Data

I developed this feature that I think can be improved quite a bit. The result is the desired one, but it took me many lines of code. Any idea to optimize it? ...
2
votes
3answers
44 views

regex check variable amount of digits

Check for Expiry Expiry can go from 1 to 299 Expiry can be 1 digit, 2 digits or 3 digits This will be the Input I check my regExp against. ...
3
votes
1answer
78 views

Parsing values from string into struct using match in Julia

My goal I am parsing from a string which contains token:value pairs into a type. Example: ...
1
vote
1answer
128 views

Coin Flip Streaks script

I am attempting to complete the coin flip streaks problem from automate the boring stuff with python. My code works fine but my only concern is the phrasing of the task. Does the question want us to ...
5
votes
1answer
77 views

Calculator that finds the area under a curve

The program is meant to collect from the user: The function under which to calculate the area The left and right boundaries of the region The amount and position of rectangles to use to approximate ...
4
votes
1answer
83 views

Check if string is palindrome LeetCode

LeetCode 125 requires receiving a string and checking if it is a valid palindrome. I have done this and am confident with an int and a single word, but this question requires the use a of a sentence ...
4
votes
1answer
176 views

Finding Pattern Score in Python

I saw this problem in C++ on here and decided to try it in Python, which was much simpler. I've used the same problem blurb as in the link above, so they are consistent. I'm sure my code can be ...
6
votes
2answers
93 views

C++17 static templated ini file reader

I've written a modern C++17 INI file reader to get access parameters values from an INI configuration file anywhere in a source file by simply included ...
7
votes
2answers
467 views

Validating ISBN-10s, with or without dashes in C++11

Description A regex-based method of validating ISBN-10 as strings. Can be digits (or 'X' at the end) only, or with dashes, according to those of English-speaking publications (which are defined by the ...
5
votes
3answers
119 views

Regex - Input Checker Class - Lambda with two lists

I have an input checker class with some RegExes, and I have converted some of the loops to lambdas. Am I doing it right? They seem to work fine, but I'm new to Lambdas. Does this offer a performance ...
6
votes
2answers
151 views

Separating data from string representation of objects, with added extras

Given a string representation of data, I want to extract the information into its corresponding object. However, If the string has "|" separators then these should be considered options and ...
2
votes
2answers
239 views

Date Detection with Python RegEx

its a practice project from "Automate the Boring stuff with Python" book. i am an intermediate level Python programmer and i tried to solve this problem with less code as possible. This code ...
7
votes
3answers
187 views

parse date and number from API results

I'm slurping up fields from an API that returns an array of fields. Each field in the array is a String that actually contains two separate fields (a number and a date). The number is enclosed in ...
3
votes
1answer
81 views

rename .html file from <title> tag with python

I have many html files saved to my computer.they have same tags like this: Rpi-Cam-Web-Interface- Page 2 - forum and the page number changes I want to rename file ...
1
vote
2answers
153 views

Python Regex to validate an email

I have written this regex to validate an email. It seems to work fine. Can someone advise on the regex used? Does it work properly or can be done in a better way? ...
1
vote
2answers
82 views

Regex to match each line in a file, with windows and/or linux line break included, even for missing line break at EOF

My requirement is to match each line of a text file, including the line terminator of each, at most excluding the terminator of the last line, to take into account the crippled, non POSIX-compiant ...
4
votes
2answers
1k views

Regular expression to get a string between two strings where the last string can also be 'end of string'

I intend to extract a URL search parameter value using a regular expression in plain javascript. The parameter can be in any order in the search query. So is there a better approach than 👇? ...
3
votes
2answers
154 views

Convert infix regular expression notation to postfix

This is a small part of a larger program for implementing a limited syntax regular expression constructor using Ken Thompson's construction algorithm. Converting to postfix before the regular ...
2
votes
2answers
81 views

Simple text parser using regexes

I'm trying to write simple parser using regexes. This is what I currently have, it looks really messy. Any tips what can I change? ...
3
votes
0answers
64 views

Early Stages of floating point class template in C++

I'm currently designing a class template to represent scientific notation or a floating-point number system. There are currently 4 distinct types: BIN, ...
4
votes
1answer
95 views

Check whether '.' and '/' are escaped properly

I'm currently using a function to check if a URL has correctly escaped two different characters: . and /. To escape a character ...
8
votes
1answer
111 views

Parse data from Input file and print results

I have written a script which does parsing to the input file and take out some values from them with respect to the node and print the data accordingly. Below is my script, and it works as expected: <...
5
votes
2answers
210 views

Can it be shorter?: DNA Sequence Analyzer from CS50 written in Python

This is my first time requesting a code review. This is code I wrote in Python to create a DNA sequence analyzer. This is for the Harvard CS50 course. I was really hoping to get some constructive ...
8
votes
2answers
279 views

Follow-up: Javascript Syntax-Highlighter for Java

Background The basics of this project have already been discussed here. I've improved the following things: Sᴀᴍ Onᴇᴌᴀ mentioned that I shouldn't use multiple elements with the same id. I corrected ...
3
votes
1answer
68 views

Tampermonkey script to check and replace youtube's subscriptions to show all videos

Just wanted a general review of the code to make sure I'm doing it properly/efficently. New to JS and don't use RegEx too often. ...
11
votes
4answers
2k views

Javascript Syntax-Highlighter for Java

Project I wanted to create a syntax highlighter for Java using JavaScript, HTML and CSS. It uses regular expressions to find the parts that should be highlighted (at the moment: keywords, strings, ...
1
vote
1answer
53 views

Simple tip calculator code

I have built a super simple tip calculator to help me try and get a hold of the javascript knowledge I've gained. I just wanted to see if there was any feedback I could get for it... Basic ...
1
vote
1answer
259 views

Python - Password Generator & Strength Checker

I am a beginner in Python and I have attempted to create a small script/program which allows the user to do the following: Generate a single random password Generate a number of passwords specified ...
4
votes
0answers
38 views

Simple Pretty-Bytes Size (SI System)

This is a simple and short "Pretty Bytes" javascript function using the SI Decimal System for quantifying bytes. The code does not use complex maths such as ...
2
votes
0answers
40 views

Genetic sequence analyzer that reads FASTA and GenBank file formats and outputs all possible gene products

I have updated my my gene sequencing program from my previous post. That post explains what each functions accomplish. If you need clarifications feel free to ask. Any tips to make the code more ...
3
votes
1answer
88 views

Parse and format var_dump data to become more readable

I have a class that exposes var_dump data in order to get better human readable layout. I have achieved this with a lot of ...
1
vote
1answer
57 views

Validating a name with C#, ASP.NET Core 3.1 and Regex

This class validates that a name contains only letters and optionally spaces, hyphens and apostrophes. ...
3
votes
1answer
90 views

Python - A Regex Text File Searcher by Content Project

I would like some advice on efficiency and ways to further remove redundant code. Regex Text File Search: enter a valid directory path, and a string to search for makes a list containing all the ...
1
vote
3answers
314 views

Python - Making A Valid Date Checker - using Regular Expressions

Date Detection: Write a regular expression that can detect dates in the DD/MM/YYYY format. Assume that the days range from 01 to 31, the months range from 01 to 12, and the years range from 1000 to ...
8
votes
4answers
2k views

JavaScript function that flips brackets direction

I have these strings: )hello( this has ]some text[ flip }any{ brackets even with )))]multiple[((( brackets As you can see, the brackets are all in the wrong ...
2
votes
2answers
103 views

Extracting min and max salary from string

What I want is to do is to extract min/max range of salary from a text which contains either hourly or annual salary. ...
12
votes
4answers
2k views

Simple C transpiler

I wrote a simple transpiler (that may be a bit of a stretch) in perl to cut down on some boiler plate code. I'm very new to perl, this being maybe my third ever project in it. My main question would ...
2
votes
2answers
118 views

Creating nested list comprehension of files starting with specific string

I have a directory with 'sets' of files that start with a state name followed by 4 or 5 digits (typically indicating year). Each 'file set' contains 3 files a .txt, a .png, and a .jpg. Example of ...
3
votes
1answer
76 views

Listing words from text, provide lines where appears, count them

I applied for Junior Java Developer in some company. Got a task:"Listing words (without duplicates) from text, provide lines where appears, count them." Output should looks like: Alphacoronavirus - 3 ...
2
votes
0answers
289 views

Spark Scala: SQL rlike vs Custom UDF

I've a scenario where 10K+ regular expressions are stored in a table along with various other columns and this needs to be joined against an incoming dataset. Initially I was using "spark sql rlike" ...

1
2 3 4 5
17