Questions tagged [regex]

Regular expressions provide a declarative language to match patterns within strings. They are commonly used for string validation, parsing, and transformation. Since regular expressions are not fully standardized, all questions with this tag should also include a tag specifying the applicable programming language or tool. NOTE: Asking for HTML, JSON, etc. regexes tends to be met with negative reactions. If there is a parser for it, use that instead.

Filter by
Sorted by
Tagged with
0 votes
1 answer
18 views

Classify E-commerce URLs into predefined classes

How can I classify an E-commerce URL Page into the following categories, Cart Payment Product Page Checkout How can I achieve this with the url and page title in my hand? I have tried multiple ways ...
  • 41
1 vote
0 answers
78 views

How to write a simple rule-based datetime range parser in python?

The dateparser package fails to detect texts like the following and generate a date range 'last 2 weeks of 2020': Should return 18th December 2020 - 31st December 2020 'first three quarters of 2018': ...
  • 11
1 vote
1 answer
71 views

Regex in R as a list for Quanteda [closed]

R newbie here. I'm doing some text analysis using the package quanteda. Basically, what I'm trying to do is put all the words follow the regex pattern ...
-3 votes
1 answer
430 views

regex for JSON only for one nested data [closed]

Hi guys do you know how to change this regex, that it only looks for test :
1 vote
1 answer
185 views

pandas series match multiple keywords [closed]

Is there a direct python pandas method to match values of series and update different series with some string ? I couldn’t find any direct method of doing it. Here the match is to find a value in a ...
0 votes
1 answer
112 views

Separate business emails from personal emails

I am working on a classification problem where I would like to separate business emails from personal emails to analyse their behaviours separately. I am thinking about using regex but after looking ...
1 vote
0 answers
105 views

Fastest way to parse regex in R

I need to parse around 1.6k REGEX expressions such as the pair I am writing below. I have also around 7k documents (1/2 page long each in average) that need to be parsed according to the REGEX ...
  • 31
2 votes
1 answer
5k views

R Studio - grepl compare a column in a dataframe to a list of pattern

I have a column named "MATCH" in a dataframe and a list of patterns named "PATTERN". ...
  • 121
1 vote
1 answer
70 views

Text comparison: spot the differences

I would like to know what would be the best approach to compare two texts and see the differences between them. For example: ...
  • 151
0 votes
2 answers
1k views

Remove all characters following a certain character in a column of a dataset

I have a data set like the following, and the first column contains the groupings. However, some are labelled slightly differently. I need to remove all characters following the punctuation used (...
  • 1
2 votes
1 answer
273 views

How to validate regex based Resume parser efficiently

I am using rule based logic to extract features from resume. Basically I am trying to find if the candidate switched the company in less than 1 year. So I have the code in place to find it using ...
  • 235
1 vote
1 answer
117 views

Is the search for a specific n-gram the same like a string search?

Is the result of a search for a specific n-gram like sherlock+holmes equal to the result of a regex search for "sherlock holmes" in the same document corpus? So if i read about n-grams for certain ...
1 vote
1 answer
95 views

How to generate abbrevations from shortend words in medical records

I have text files which contains medical history of a patients and would want to extract information out of it. Basically what want is generate english text of abbrevations,semantic category region,...
1 vote
2 answers
73 views

How to improve regex while fetching record dynamically

The data is as follows: COL1 COL2 12 :402:agsh,hhjd,:45:hghgh,gruru,:12:fgh,ghgh,:22:hhhh 57 :42:agshhhjd,:57:hghgh,gruru,:120:fghghgh,:12:hhhhhh I ...
1 vote
2 answers
208 views

Keeping part of a string in R [closed]

I have a dataframe with the following column city <- c("Sydney NSW", "Newcastle NSW", "Liverpool NSW", "Broken Hill NSW") I want to maintain everything prior ...
0 votes
2 answers
308 views

Replace method in pandas not giving expected result

I have data as below: 123.12.23.2 110.22.21.23 I want to mask this data as below one 1xx.xx.xx.x So I tried below code : ...
0 votes
1 answer
368 views

How to filter out a portion of the text data with re.match or any other regex method with Python?

I have the following data : ...
5 votes
3 answers
2k views

Machine learning or NLP approach to convert string about month ,year into dates

I'm currently in the process of developing a program with the capability of converting human style of representing year into actual dates. Example : last year last month into December 2018 string may ...
  • 201
1 vote
0 answers
216 views

simplifying AND OR Boolean Expression [closed]

My problem is turning a string that looks like this. "a OR (b AND c)" into a OR bc if the expression is like ...
  • 201
1 vote
1 answer
283 views

Tagging Unix/Non-Unix logs using NLP

I have a set of unstructured data consisting command output logs for different operating systems like Unix, Windows, etc. For example: Releasing version 0.0.1 for Stackoverflow, on 01/01/2019. The ...
4 votes
1 answer
683 views

Regex-style pattern-matching for time series

This is more of a "what technology/library would you use for this?" question than anything else. I have categorical time series data, and need to match cases in these time series to known patterns. ...
  • 1,097
4 votes
1 answer
251 views

How to automatically verify official documents?

I am new to machine learning and data science. I apologise if the question seems very basic. I have a requirement where I need to verify information submitted via a form with the corresponding ...
4 votes
2 answers
15k views

regex to remove repeating words in a sentence

I am new to regex. I am working on a project where i need to replace repeating words with that word. for example: I need need to learn regex regex from scratch. I need to change it to: I need ...
2 votes
1 answer
3k views

How to customize word division in CountVectorizer?

...
2 votes
1 answer
278 views

Facing a difficult regular expression issue in cleaning text data

I am trying to substitute a sequence of words with some symbols from a long string appearing in multiple documents. As an example, suppose I want to remove: ...
  • 1,067
0 votes
1 answer
1k views

Regex remove 1-2 character sequences: hyphens literal, not word boundaries [closed]

I need a regex in R to exclude 1 or 2-character words, but which does not treat hyphens as word boundaries. Here is an example: ...
2 votes
1 answer
4k views

How to improve OCR (Scanning) results?"

Below is text output obtained after ocr image to string of medical discharge summary report. ...
  • 91
0 votes
3 answers
501 views

Using training data generated with pure regular expressions - Can machine learning surpass the accuracy of your regular expression?

For text classification with machine learning - If your training data was generated purely with regular expressions, is it possible to train a machine learning model with this training data which will ...
2 votes
2 answers
2k views

Regular expression in python -

I want to extract the values of the below text ...
  • 91
4 votes
2 answers
2k views

What is the best approach for specified optical character recognition?

I have a quite understandable request of extracting information (invoice number, invoice data, due date, total etc.) from scanned invoices (the digital format is image, not PDF), preferably in Python. ...
  • 8,247
1 vote
1 answer
6k views

R: remove single characters from string

I have a huge string in R where I want to remove single characters from. So for example, the string might be blabla a test this that b á And the result should be ...
  • 11
1 vote
1 answer
1k views

Using regex in redshift to find dollar values

I have a field in a Redshift table that has user-generated text. The field is where users can say how much they think something costs. Ideally it'd just be a decimal, but it's varchar. So users can ...
  • 323