Most voted "regex" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to regular expressions. Regular expressions (usually abbreviated as "Regex", "regex" or "regexp") are a declarative language used for matching patterns within strings. When asking, also include a tag specifying the programming language or tool you are using to identify one of the different dialects.
Learn more…1,253 questions
Sort by count of
-
1
votes1
answer157
viewsCatch multiple occurrences of an expression in parentheses
I’m building a truth table, where I get an equation with several propositions (q, p, r, s) and connective (!, *, =). My equation comes in the following format: String equation = "!(q+p)*r=(s+r)";…
-
1
votes3
answers379
viewsHow to take a value among many keys, but ignoring the keys, except the most internal?
I’m trying to get the value that’s inside the keys. Example: {{{{{{{{{{{{{{{{{{{{Valor aqui dentro}}}}}}}}}}}}}}}}}}}} I’m doing the tests on Regex101. I wanted the end result to be like this:…
-
1
votes2
answers93
viewsRegular expression by string index
Consider this variable: x <- c('horccaeon', 'coleon', 'volues', 'mol', 'nao', 'tom', 'nada', 'auio', 'aqoio') I used the following regex to extract strings with the second letter o:…
-
1
votes1
answer402
viewsIllegal group Reference error
You’re making a mistake on a replace what I’m doing. The string in question is this: <table id='tablecritica' class='table table-bordered table-hover'> <tbody> <tr> <td>…
-
1
votes1
answer154
viewsExtracting email addresses from a web page using regular expressions in python
What I did: from urllib.request import urlopen from re import findall def emails(url): content = urlopen(url).read().decode() #print(content) padrao =…
-
1
votes1
answer95
viewsA single regex for two different options
How can I use the regex twice type like this: let A = /^A2\d{8}.{26}\d{12}$ , ^A3\d{16}.{26}\d{15}$/; What would be the way to use it to A2 and A3 without having to use regex twice, like: let A =…
-
1
votes1
answer127
viewsHow to make a regex to treat the text this way?
Whereas I have random classes, may or may not have a class in the paragraph. I need to put an empty paragraph, when there is not an empty paragraph on top of the text. I can receive texts in these…
-
1
votes2
answers437
viewsRegex to find text between square brackets
I’m trying to create a regex to identify the following occurrence: [Ticket: 20021501280806] I need an expression that identifies the ticket number, but only within the string [Ticket: ]. Actually I…
-
1
votes1
answer129
viewsRegex to take a stretch that may or may not occur
I have a phrase, where before and at the end of it I have {{ and }} Example: {{UMA FRASE DE EXEMPLO}} In some cases, I may have a parameter for that phrase. To identify that it has a parameter I use…
-
1
votes1
answer58
viewsRegular expression: how to apply "Negative Lookahead" to only one capture group?
In a domain validation task, I need a regular expression to validate them by following some rules, among them, where the domain name does not only contain numbers. Therefore, I created a regular…
-
1
votes2
answers152
viewsCan anyone explain to me how this code works?
I can’t understand the use of prototype.allReplace nor the use of RegExp. What are these parameters? String.prototype.allReplace = function(obj) { var retStr = this; for (var x in obj) { retStr =…
-
1
votes3
answers122
viewsHow to obtain the contents of an HTML element from a Regex string?
I am creating an application that reads the content of a page on the internet and then gets the text of an element <textarea> of that content. To accomplish such a task, I decided to use…
-
1
votes1
answer2137
viewsMethod Matches() to validate if string contains only numbers
I’ve read some articles on the method matches() and really didn’t understand. In that code would return false because I am using a variable and the method read the variable name and not the value…
-
1
votes1
answer101
viewsData munging with python
Are the following date formats: 042555 04/25/1955 Abril 25, 1955 How to use regex to transform a date format into each other (would be 6 transformations)? For example: Entrada: 042555 Saída:…
-
1
votes1
answer74
viewsHow to do this Regex in Delphi
I’m having trouble making the following mask. Valid values: 1.98.212 1.98 1 What I’ve managed to do so far: \d{0,1}(\.\d{0,2})?(\.\d{0,3})? You’re wrong because you can insert 1,999, because…
-
1
votes1
answer88
viewspreg_match_all does not return all values
I need to get the page titles of a txt but can’t get the correct output values with preg_match_all, always returns me only the result of the last IP line of the.txt file. My code: <?php $arquivo…
-
1
votes1
answer66
viewsRegex only in word without predecessor or successor of dots or bars
I would like to get the result of the occurrence without successor or predecessor of points or bar, I have my cases in the database: Registro 1: VERSION01/VERSION01.5/VERSION01.5.5 Registro 2:…
-
1
votes0
answers71
viewsRegex.Unescape() does not work
My project has a class with the type property string which receives the XML of a Tax Note signed by SEFAZ. The system must send the property as a parameter to a WebService that only returns an…
-
1
votes1
answer268
viewsRegex to capture unique numbers within a string
I’m trying to create a Regex that captures only unique numbers in the middle of other characters (as long as they follow the condition of not being followed by other numbers). Examples: "R3g3x":…
regexasked 4 years, 6 months ago Zeca Novaes 121 -
1
votes2
answers294
viewsRegex does not take all span tag strings
I know there are HTML parsers, but since my HTML is not well structured, I also need to use regular expressions. The HTML is like this: <tr bgcolor="#CCCCCC"> <td colspan="2"><font…
-
1
votes1
answer67
viewsRegex to pick up everything in parentheses in certain situations
I need to create a regex to extract from a code everything that is passed as a parameter for the functions, but can only be captured in certain functions. I have the regex that takes everything in…
regexasked 4 years, 8 months ago Lucas Rivoiro 33 -
1
votes1
answer1109
viewsRegular expression to validate car plate
I would like a regular loan to validate license plates. Today in Brazil we have 2 models: the old and Brazil. The difference is that in the 5th character, in the South is only text while in the old…
-
1
votes0
answers27
viewsHow to get the last numbers with REGEX?
i need to get the value of CSLL, q in case it is 458,33. I tried every way to capture it before the word "VALUE" but it did not work. follows the text: IRRF PIS/PASEP COFINS CSLL 0,00 297,92…
regexasked 4 years, 2 months ago Davi Freitas 21 -
1
votes1
answer48
viewsHow to remove a word from a string and all the other subsequent ones?
I have a string url and I need to withdraw the word Dashboard and all subsequent characters (including bars). Example: "Algumcoisa/Dashboard/Outracoisa/Maisalgumacoisa" I want you to stay like this:…
-
1
votes1
answer105
viewsRegex to select only a number within certain Strings
I have a multi-line log that generates multiple events, however I need to take the . and take only the information that is before the "ms", ie "509833", "780414", etc. 2020-04-23 15:21:10,602 INFO…
-
1
votes1
answer75
viewsSplit String into blocks, considering only letters or text in square brackets
If I have a string like that: "Olá, o meu nome é [José Cavalo]" And I der split: {"Olá,", "o", "meu", "nome", "é", "[José", "Cavalo]"} First of all, we have a problem. At 0, we have "Olá,", and we…
-
1
votes0
answers25
viewsWhy use re.Compile? What’s the difference between using only the desired Pattern?
We can find some difference when using re.Compile inside Python? Assuming a file with 10 lines composed by dates and a file with 10,000 lines of dates. A Pattern could be pattern =…
-
1
votes2
answers326
viewsRegex to capture links from sites specific to an HTML page
My goal was to make a Rawler web that found links (in many ways, but starting with http/s) in the HTML page of a site, I used requests and regular expressions, a part of the code went like this:…
-
1
votes1
answer128
viewsFix badly formatted JSON
I receive a totally non-standard JSON from a customer. And as always, the customer is always right :-( JSON arrives as follows: { dominio:casadasloucas.com.br,…
-
1
votes1
answer58
viewsFind values in blocks that extend across multiple lines
I have a Arquivo Espelho that contains coupon mirrors, and I created an algorithm to separate the coupons: import re txt = open("arqEspelho.txt", 'r+').read() x = re.finditer(r".*COTIA\s*C*", txt) z…
-
1
votes1
answer87
viewsRegex in the input frame always valid
I have a form as long as the visitor can enter the phone and am trying to valid using the input Pattern attribute using a regular expression I found in a post on Medium:…
-
1
votes1
answer22
viewsRegex to get result from above line
I have the OCR below and would like to get the result in regular expression. Of: 1505 - ADMINISTRACAO DOS PENSIONISTAS DO IPREV, above the word CPF. I thought of using the CPF as a parameter,…
regexasked 3 years, 3 months ago user2254936 185 -
1
votes2
answers170
viewsConvert a string in monetary format to number and subtract 90%
How can I convert a string to number and subtract 90%? I tried to make a code (below), but it returns the value 3205.5 and I’m not getting to know why. If I use the value R$ 320,50 works. var a =…
-
1
votes1
answer64
viewsRegex for numbers of different sizes
I need to read an image . png with a financial handling table, like the one below: From this table I need to extract the columns gross balance, availabilities, Application/Redemption and Final Gross…
-
1
votes1
answer202
viewsHow to use the negation operator in regular expressions for a specific string?
Studying the negation operator in regular expression ([^]) regular, I understood that it is possible to deny an isolated character (e. g., [^x]: anything other than "x") or a range of characters…
-
1
votes2
answers68
viewsRegex extract substring from text delimited by an end pattern that repeats in the text (Starttextofim Starttextofim)
I aim to perform the extraction of the substring delimited by ENTER and Tempo de viagem total:4h 05m in the text below: For this I built the following regular expression: ENTER[\S\s]+Tempo de viagem…
-
1
votes1
answer28
viewsHow do I egrep print the matchlist of a file?
I’m reading a book of regular Expressions where the author uses egrep to show some examples. It happens that when I try to replicate the examples on my computer my output is different from the one…
-
1
votes1
answer99
viewsJava: separate row into columns by character position
Hello, I turned the internet upside down trying to solve this problem. I have a text that in this format: 012016010402AAPL34 010APPLE DRN R$…
-
1
votes1
answer248
viewsUsing regex to convert latitude and longitude coordinates of degrees/minutes/direction to decimal in python
I am trying to convert latitude and longitude data into python which are in the following format: Latitude Longitude 27º59' N 86º55'E This data was extracted from the following web page and…
-
1
votes1
answer165
viewsRegex to catch files with certain characters in the name
I was in charge of creating a code that navigates to the server folders looking for files with wrong nomenclature (Accents, spaces, punctuation and special characters..) where I have broken through…
-
1
votes2
answers65
viewsCorrect unbalanced parentheses
Given a string filled with any number of parentheses, find the minimum number of parentheses to be included in the string so that it is valid. Examples: Input "(()()" must return: 1 - "(()())" Input…
-
1
votes1
answer42
viewsCan you insert a variable by passing it as a regular expression in the awk command?
Example: VARIAVEL="Pará" echo "$VARIAVEL" | awk '/^P/ { print $1 }' What this does is just search for any word started with a capital letter P. Okay, so far so good! Now, I want to know if you can…
-
1
votes4
answers120
viewsHow to filter an HTML tag and its contents with regular expressions in Shell Bash?
Based on the text below, how to keep the text output from the first column of tag span, that matches the text of the latter span? <span class="CVA68e qXLe6d">Colcha Casal e ... -…
-
1
votes3
answers74
viewsPicking numbers from a string - python
How could I get just the digits of that string? <SCANNER A7899739503929> I’ve tried using the findall, but unsuccessfully it returns me several separate numbers: import re txt =…
-
1
votes1
answer40
viewsHow to identify words that start with a character and end with the same plus a space using regex?
/(\*[ ]|\_|\~|\@\@|\%\%)([^\s].*?)\1/gm When I add the expression *[ ] (highlighted in red) to consider the space after the * it starts to consider everywhere and I need it to be only at the end of…
-
1
votes1
answer72
viewsRegex for a valid YYYY year in java?
I am using these regular expressions for a future date check: Pattern padraoDia = Pattern.compile("([1-9]|0[1-9])|[1-2][0-9]|3[0-1]"); Pattern padraoMes = Pattern.compile("(0[1-9]|[1-9])|1[0-2]");…
-
0
votes1
answer196
viewsHow to validate the price in Qt?
I would like to know how to validate the price in Qt, as follows: Accepted examples: 10,00 / 100,00 / 1.000,00 = true My code, (but it’s validating true: 10 / 100) bool ok;…
-
0
votes1
answer402
viewsWhich regular expression to use to replace all occurrences found in an Eclipse file?
Well, I have a CSS file of over a thousand lines, where for every class listed there, there is a code @external stating the same, example: @external agora-eu-posso-usar-minha-classe;…
-
0
votes1
answer98
viewsHow to take the content of the JOIN clause condition
I have the following situation that can be seen in this link. The expression is: /((^|\s)(right|inner|left)\sjoin\s(.*?)on\s(.*?)(?=(inner|right|where)?))+/gmi I need to get the conditions inside…
-
0
votes2
answers159
viewsRegex in Mysql to fetch certain X tempo results
I have a field in the table defined as DATE and the data is saved in this field as follows: year-month-day hour:minute:second Exemplo: 2014/04/22 18:32:00 I need to develop a query that returns me…