All Questions
Tagged with regex performance
98 questions
6
votes
2
answers
713
views
Weather Observation Station 8 query
Here's my (correct) solution to a HackerRank question:
Weather Observation Station 8
Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last ...
2
votes
2
answers
151
views
Faster regex to match all worded numbers from 1 to 99
I would like to know if there is a better regex to match all worded numbers from 1 to 99.
With "better" I mean shorter with same performance, OR faster.
I came up with this. I can't do ...
4
votes
4
answers
2k
views
Matching words from a text with a big list of keywords in Python
I implemented the following code to retrieve medication names from a given text (prescription_text in the code). It works by matching words in the text with a list ...
0
votes
1
answer
93
views
Parsing shortcodes out of a string
I wrote this shortcode parsing and it runs in \$O(N^2)\$. Is there a way to better optimize this?
...
1
vote
2
answers
328
views
Replacing banned words from a given text
The following algorithm is used to find a word from Blacklisted words in a string (called text) and replace these words with censored text, as shown in the example.
Example:
...
2
votes
1
answer
261
views
Extract regular words from string but retain all other elements and record their type
This snippet processes every regular (\w+) word in a text and reinserts the processed version:
...
0
votes
1
answer
68
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
...
2
votes
2
answers
923
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
1
answer
63
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
3
answers
686
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?
...
1
vote
2
answers
3k
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 ...
3
votes
1
answer
473
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
2
answers
1k
views
Tokenizing a large document
I'm currently trying to process a corpus of a million patent text files, which contain about 10k non-unique words on average. My current data pipeline works as follows:
Load the patent texts as ...
1
vote
3
answers
1k
views
Check browser compatibility for RequestAnimationFrame and Vanilla JavaScript .animate() API
I'm trying to set up some code to first test if the Vanilla JavaScript .animate() API is Supported, then if it's not check if ...
3
votes
3
answers
176
views
Java regex and replaceAll to extract strings into objects
I have this method that creates book objects. I pass a list of strings (size 60000+) that contain the information of the book, the function then goes and extracts the information makes the book object ...