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
-
2
votes1
answer155
viewsREGEX - problem with validation
I need to do the following validation: a-z (upper and lower case), hyphenate (-), apostrophe (\'), space ( ) and numbers (0-9) For that I did the following: import java.util.regex.Matcher; import…
-
2
votes1
answer216
viewsRegex PHP problems
I am trying to get some information from a web page and I am using regex for such. I’m using regex101.com to test the Pattern and I managed to reach one that suits me perfectly. It turns out that…
-
2
votes1
answer109
viewsKeep characters in replace with regex in gedit
I have the following text segment in a . csv file 5/29/17;08:17;Fulano;Teatro Companhia Rua do Canto, 301/305 Esquina da rua meio De segunda a sexta das 9h as 18h 5/29/17;08:18;Ciclano;legal I need…
-
2
votes1
answer210
viewsGet part of a string with Regular Expression - C#
Based on the string "Plan Liberty Company +50 - 043-98965-2784(058/POST/SMP)", I need to get the part of "043-98965-2784". I realized that in the txt file I’m using, the numbers follow the pattern…
-
2
votes1
answer390
viewsMask with Regex and replace to allow single digits and a single hyphen
What I need: A mask that works in the event keypress of a TextBox replacing what is not numerical and excessive hyphens with "". What is my difficulty: Check the entry of only one hyphen in the same…
-
2
votes0
answers201
viewsCounting the number of connections per IP to a web server on port 80. Is regex correct?
I would like to count the number of connections per IP per second (at port 80) to a web server whose IP is 192.168.1.216. The input for the count is a network dump file in the PCAP (.pcap file)…
-
2
votes3
answers709
viewsHow to capture repetitions of a given group with regex?
I’m trying to capture a certain structured data, and I need it to capture a certain group as long as there are possibilities. The data format is as follows: foo01@chave1|valor1#chaveN|valorN Where…
regexasked 7 years, 2 months ago LeonanCarvalho 3,527 -
2
votes1
answer260
viewsSplit text
I need to take a specific piece of a file . txt that is between <tag> and </tag>. But I need to get all the lines where it happens. Example: <tag1>titulo</tag1>…
-
2
votes1
answer297
viewsUse of the preg_match
With this code I can block special characters in my input, but I still want him to accept ., - and _ how to proceed? elseif (!preg_match('/^[a-z A-Z0-9]+$/', $username)) { echo json_encode(array(…
-
2
votes3
answers3777
viewsRegular Expression - Name + Space + Surname
Hello ,I’m looking for a regular expression to validate name and last name requirement. But she must accept accents and a specific case that would be: Igor D Sant
regexasked 6 years, 11 months ago Igor Siqueira 120 -
2
votes1
answer815
viewsInput read more than one string line
I’m having a problem, my code needs to read a string that contains more than one line, however it reads the first and to, as if when the line is skipped, it interprets as a "enter". def…
-
2
votes1
answer2355
viewsUppercase and Lowercase Letters only and regular expression accents
How to create a regular expression in the right way where only uppercase and lowercase letters are accepted, along with accents? This is to validate a string by name, I created it as follows:…
-
2
votes1
answer102
viewsArrows do not move in text field with regex
I have the following code with a regular expression inside a method Keyreleased, which allows only some characters to be typed by the user in a text field: String text = input.getText(); text =…
-
2
votes3
answers6001
viewsRegex returns False when validating card
I’m trying to validate a car plate in the format : ABC1234 3 letters and 4 numbers. let regex = new RegExp("/[a-zA-Z]{3}[0-9]{4}/"); let isvalid = regex.test('abc1234'); When I put it on other…
-
2
votes1
answer118
viewsAppropriate PREG MATCH rule
I created a loop that shows all months of the year with the following code: for($i = 1;$i <= 12;$i++){ } then I created a $_GET variable that would receive a rule like the following:…
-
2
votes1
answer717
viewsSeparating a paragraph by sentences
I need to break a paragraph into a set of sentences. For example: var paragrafo = "Sou Dr. José. Meu passatempo é assistir séries. Adoro animais!! E você?"; var frases = paragrafo.split('.') But he…
-
2
votes1
answer58
viewsChange Javascript string characters for successors
I have a string, for example, acbd and want to get another string bdce, formed by the successors of each character. In my searches find a possible way that is to transform the string into an array…
-
2
votes1
answer667
viewsFind all occurrences of a pattern in a String
I need to use regular expressions to find patterns in a text. It would be better for me if there was a method like search() Python, which returns an array with all occurrences of this pattern. There…
-
2
votes3
answers304
viewsWhere is the error in replace js?
t = "(10px,10px)" t = t.replace(/-|\d+/g,3,5) I wanted it to result in (3px,5px) Where is the error?
-
2
votes2
answers2215
viewsRegular expression to find numbers in between words
Currently I am developing a project of which I am using regular expressions to find certain patterns, however there is a String specific and need to extract two numbers from this, the expression is…
-
2
votes2
answers4154
viewshow to create a currency mask with regex
hello, I’m beginner with angular 4, I’m trying to make a mask for a text type field to validate a value in m². The Mask class contains the method to create the mask, the given value can be between 1…
-
2
votes0
answers377
viewsRegex for name validation with Posix regex
I have a function in c++ validates name and surname with the following regex : "((?:[á-úA-Za-z]+[ ]+[á-úA-Za-z]{0,20})?)?" was taking a look to let learn to create regex otherwise based on what is…
-
2
votes1
answer277
viewsAccount Plan Mask in javascript
How can I do a javascript function to format the values typed in an input to the default account plan similar to the one below. 1 (min) 1.1 1.1.1 1.1.1.01 1.1.1.01.001 (max) Column Bill…
-
2
votes2
answers70
viewsExtract portion of characters using PHP
Hello guys I have the following string: '<a href="http://localhost/mensageiro/1990/">1990</a> (1) <a href="http://localhost/mensageiro/1994/">1994</a> (2)…
-
2
votes2
answers1412
viewsRegex to give match on first occurrence before a word
My string is as follows: \questao{1} \begin{enumerate} todos os tipos de caracteres \end{enumerate} \begin{enumerate} -------> APENAS este deve dar match todos os tipos de caracteres…
-
2
votes2
answers473
viewsRegular expressions C++
I have a text with the following formatting Concept:personasia:toby_pizur:personasia:test How do I get a string with this format, only the text after the last two points(:) ? In the example above, I…
-
2
votes2
answers204
viewsHow to select text between spaces - REGEX?
I have a string like this from Names: var names = ' GEO X GEO3 X GEO4 X'; and I need to split using regex to separate in the arrays only texts that are between spaces and that are not X tried so:…
-
2
votes2
answers83
viewsRegex - Expression for catching limited fields
I have the following string: "Let's put some bits in your home" Using regular expression, how could I get only the information from bits forward, getting: bits in your home That is, the other words…
regexasked 6 years, 6 months ago Maicon Queiroz 47 -
2
votes4
answers721
viewsHow to replace with ' ' ' character with Regexp?
I need the ' ' (Reverse Solidus) character to be included with the captured group value. Example: In the sentence Assets/pdf/regulation_demais_ddds_ Hi Mod.pdf, I need the stretch /pdf be replaced…
-
2
votes1
answer336
viewsDelete chunk from a string with replaceAll
I have a string, example: &texto-outroTexto=09213sdadwqWDQS Where "09213sdadwqWDQS" would be any text and "&texto-outroTexto=" would be a fixed text. I wanted to do the Regex of that string.…
-
2
votes1
answer84
viewsRegular expression to validate a field
I have an input in the form that should accept only the following formats: Examples 1AB 1AB2CD 1AB2CD3EF The minimum size has to be 3 and the maximum 9, and always follow the standard 1 digit and 2…
-
2
votes1
answer61
viewsCapture with regex certain part of the string
In this sentence, /comprar/volkswagen/gol/11184529, I’d like to capture if the word exists comprar what comes next without the /, I would like to capture the word volkswagen (but it could be another…
-
2
votes1
answer139
viewsSearch Array with case-insensitive javascript variable
I need to search an array with values of the type: equipamentos = [{marca: 'Nomedamarca1', modelo: 'Modelo1'}, {marca: 'Nomedamarca2', modelo: 'Modelo2'}, {marca: 'AlgumNomeComCase', modelo:…
-
2
votes2
answers737
viewsHow to replace a space by semicolon between two words with gsub()
I have a problem to solve and I can’t write the correct regex. I want to add the semicolon between two emails: ex <- "[email protected] [email protected]" #resultado esperado: [1]…
-
2
votes1
answer1096
viewsApply Mask to Java back-end
Does anyone know how to include a mask from a regex in a string? For example, I own the following regexString pattern = "\\d{2}[/]\\d{3}.\\d{3}[/]\\d{4}";and a variable with the following value…
-
2
votes2
answers2417
viewsHow to remove repeated characters from a string?
This is my job: let longest = (s1, s2) => { var s1 = `xyaabbbccccdefww`; var s2 = `yestheyarehere`; let res2 = s1.concat(s2); console.log(res2); };…
-
2
votes1
answer73
viewsRegex in word XML
I have an xml that came from a docx in this format: <w:p w:rsidR="00AE2D8E" w:rsidRPr="00AE2D8E" w:rsidRDefault="00AE2D8E"> <w:pPr> <w:rPr> <w:lang w:val="en-US"/>…
-
2
votes2
answers1242
viewsRegex to extract email address from a string
I’m trying to make a regex so that it only takes the amount between < and >. But I’m having a hard time. Follow an example: teste <[email protected]> Regex I tried to create:…
-
2
votes1
answer174
viewsString search with character "|"
I need to perform a query in a txt file in Python, but I have 2 problems due to interpretation of special characters. When I insert | or \ the result is replaced: the | is addressed as white space…
-
2
votes2
answers1681
viewsRegex required number(s) and optional letters
I have this regex to validate, but it is not working properly, it needs to be mandatory number, can be more than one, and optional letters. (?:\\d+[a-z]|[a-z]+\\d)[a-z\\d]* This is required 1 letter…
-
2
votes1
answer1913
viewsRegex to validate national document number
I am trying to create a national document validator that accepts numbers and letters or only number with 11 characters limit in Javascript. The problem is in the creation of regex. Follows the code:…
-
2
votes2
answers115
viewsProblem capturing the title of a URL using regular expression
I’m learning Go language in the competition part. I had the challenge of using the Generator standard to get a Channel that reads the title of a URL through a goroutine. Inside this goroutine that I…
-
2
votes1
answer142
viewsRegular Expression is correct but does not enter if
I wonder why my code isn’t getting into this if more internal. I tested regex for some websites and it’s working. I tested with this value: nucepe-2018-pc-pi-perito-criminal-informatica-prova.pdf.…
-
2
votes2
answers4377
viewsRegex for monetary values
I would like to know how to do a regex to capture a monetary value with semicolons. Ex: 7.300.250,00
-
2
votes1
answer301
viewsRegular expression to validate text
I am making a method that will import some data, and before the import I need to check if some fields are correctly filled, the fields should come this way: Example: Jan/Seg Fev/Ter Mar/Qui The data…
-
2
votes1
answer63
viewsRemove tags generated at the end of a string from a Text Editor
I am using a text editor and like others I have used, it always generates some useless tags that I would like to remove. I can remove the last, but sometimes it generates more than once. My code:…
-
2
votes1
answer1546
viewsRemove score from a Python file
I have this code: dataClean = ''.join(data).lower() dataClean = re.sub(r'["-,.:@#?!&$]', ' ', dataClean) print(dataClean) Where data is an array of a text file. My goal is to remove punctuation,…
-
2
votes2
answers899
viewsJavascript function for email validation does not enter Else
Can someone tell me why that function can’t get into else? When the email meets the function it usually works only when it does nothing, ie the function recognizes that the condition of the if is…
-
2
votes2
answers867
viewsReplace string with regex in python 3
I have a code that replaces certain string with whitespace dados =…
-
2
votes3
answers927
viewsRemove a part of the URL
I have this URL: https://teste.teste.pt/sites/teste/Normativo/NormasDeProcedimentos/Documents/Histórico/ How could I return only NormasDeProcedimento/ of the URL with Javascript and save in a…