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
-
4
votes2
answers330
viewsHow is the find function implemented?
Unlike match() looking for an occurrence of a language y in the beginning of the string, the find() makes a quest for y inside that string. I could use the algorithm of Knuth-Morris-Pratt to search…
-
4
votes1
answer330
viewsClassify a text array using regular expressions using R
Let’s say I have the following array of texts (character): d <- data.frame(id=1:3, txt=c('Um gato e um cachorro', 'Cachorros jogam bola usando alpargatas', 'gatinhos cospem bolas de pêlos'),…
-
4
votes1
answer487
viewsHow to use escape characters in a string in C#?
I am unable to scan a file that contains the EICAR (Standard Test File for Antivirus Scanning Methods) characters, as it contains escape characters such as " ", "()", "[]". I need a help to identify…
-
4
votes3
answers3898
viewsHow to 'break' a text at each character range - Javascript
I would like to know how to 'break' (split function) a text every 8 characters in javascript for example: var teste = '1234567898' teste.split({a cada 8 caracteres}) //retorna ['12345678', '898'];…
-
4
votes1
answer400
viewsLine break interferes with regular expression capture
I’m needing to capture some Divs information that are sometimes separated by breaking lines, and this makes the operator (.*) capture not. For example, I have regular expression: <div…
-
4
votes2
answers2734
viewsRegular expression to retrieve strings starting with colons (:)
I need a regular expression to retrieve a list of strings starting with the two-point character (":") and ending with the space character or end of parentheses (")"). Example: String texto =…
-
4
votes1
answer734
viewsRegex take more than one occurrence in a string
I have my regex (\d{2}). And I got my string 12 hoje vai 45 na serra pelada 55 ou 75. How do I get my regex to pick up all occurrences of the string? It’s only picking up the last one.…
-
4
votes3
answers2212
viewsHow to use replace() for the last occurrence?
The method String#replaceFirst() is used to replace the first occurrence of a substring in a string, but how should I proceed if I want to do this with the last occurrence? The doubt is as follows…
-
4
votes2
answers1288
viewsreplace using regular expressions
I am running a replace with regular expressions to format a string, such as CPF: var cpf = '99999999999'; cpfFormatado = cpf.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$+');…
-
4
votes1
answer2920
viewsRegular expression in Delphi 7
Guys, I’m new to programming on Delphi 7, and also regular expressions. Delphi 7 because in the company I’m working at, for other reasons, they have to use Delphi 7. I need to work with regular…
-
4
votes1
answer96
viewsProblem with Regular Expression
preg_match('<[ \w"=]+name="xhpc_composerid"[ \w="]+>',$exec,$result1); echo $result1[0]; //input type="hidden" autocomplete="off" name="xhpc_composerid" value="u_0_1k"…
-
4
votes2
answers283
viewsRegexp does not take input value
I need to extract the value of a tag html <input value="2530317385" name="X-Tmx-session-id" id="X-Tmx-session-id" type="hidden"> I’m wearing a Expressão Regular to return the value of input…
-
4
votes2
answers682
viewsFilter String Array records by space-separated words in Java
How do I filter the records of a Array using the search terms separated by space ? Example: I have a Array String with the following records. bottle opener box with blue padlock Brass padlock 30mm…
-
4
votes2
answers1907
viewsPick date and time from a string
I’m looking to "filter" the string to obtain only the date that is on it, the string is in that format: SSC Napoli v Dnipro - Thursday 07/05/2015 16:05 Hours The I want to take is just the…
-
4
votes1
answer79
viewsWhat exactly is the "u" modifier for?
What exactly does the modifier u in the regular expressions of preg_ in PHP? It is recommended to use it whenever processing strings that have accentuated characters? $valor = 'ãẽi ouã';…
-
4
votes2
answers367
viewsRegex in dynamic string X characters, in dynamic content
Next, I have a page that generates a shuffled content with dynamic and non-dynamic strings, I need to take a dynamic value between separators |, it contains random data/strings around, which change…
-
4
votes5
answers2182
viewsHow to select a full xml/html tag with Regular Expression even if there are identical tags internally?
I am trying to do the following processing in a javascript string using ER (Regular Expression): With that input: um <b>negrito<b>negrito interno</b>externo</b> aqui…
-
4
votes1
answer317
viewsHow to make Regex to a "serial" number format?
How to make Regexp of the following format: 2015.1.123.5432 Does anyone have any idea?
-
4
votes1
answer156
viewsRegular Expression, picking numbers between two predefined texts
I need to withdraw números of a string. To string follows a pattern: http://www.meudominio.com/1789519-texto The number will always be between / and - I’ve already reached the following formula:…
-
4
votes1
answer360
viewsMake text editor with syntax Highlight
How can I make an Highlight syntax HTML system for a text editor? I thought of using a tag <pre> with the contenteditable="true", then using Regex I would replace the syntax of contentText,…
-
4
votes2
answers960
viewsPreg_replace for Preg_replace_callback
I’m having trouble migrating one script mine that clears characters from a sentence. The preg_replace (depreciated) I use the value and key of the array for the exchange, however the…
-
4
votes2
answers986
viewsregular expression replacement - reference followed by number
Situation I was performing a replace of some data when I came across a peculiarity. |C405|01102015|7|1058|174544|19836903,14|18657,06| |C405|02102015|2|1059|174792|19859872,19|22441,55|…
regexasked 9 years ago Guilherme Lautert 15,097 -
4
votes2
answers417
viewsUse of the GREP Function
Hello, I have a . csv file with the zip code in the middle of the address, in square brackets. In some cases there is no zip code, but there is always the set[], possibly empty, for example: RUA…
-
4
votes2
answers545
viewsFind string inside a php tag
When using in various types of embed from various websites, go only search for the link. For example: Youtube: <iframe width="420" height="315" src="https://www.youtube.com/embed/HLhuNbO0egU"…
-
4
votes2
answers1169
viewsRemove HTML tags
In terms of efficiency and performance, which of these codes is the best option to remove HTML tags in a string? Option 1: string ss = "<b><i>The tag is about to be…
-
4
votes2
answers1086
viewsRegular expression to detect the credit card flag when there are specific characters in the number
I need to create a regular expression (Regex) that can identify the card number even when there are specific characters between the numbers, Example: Current regex:…
regexasked 8 years, 10 months ago Marcus Souza 41 -
4
votes1
answer1282
viewsRegular expression formatted as internet domain
How to create a regular expression to validate an internet domain? The rules are below: Minimum size 2 and maximum 26 characters; Valid characters are letters from "a" to "z", numbers from "0" to…
-
4
votes2
answers236
viewsDo Regex.Split on what is not between "..."
Which regular expression I use to get the comma character that is not inside the fields "...", example: line1, "line2", "hello,world", 215, X + Y ^ ^ ^ ^ I want to get only the nominees, I’m using…
-
4
votes2
answers1031
viewsHow to extract a specific string snippet
Let’s have this URL extracted /ac/rio-branco/xpto-xyz-1-0-16-5-abcd-a1G57000003DE4QEAW And I just want the piece that starts with a1G, someone knows how I only get this bit?…
-
4
votes1
answer192
viewsUppercase Roman numerals with ucwords() or ucfirst()
While typing this question I modified some things, which made me able to solve the problem. That’s why I’m creating this "share the knowledge" in case someone has the same problem. Suppose the…
-
4
votes2
answers12937
viewsValidate CPF with Javascript Regular Expression
Guys, I’m trying to validate CPF only with regular expressions.. I’ve already been able to validate the format... 000,000,000-10 ^([0-9]){3}\.([0-9]){3}\.([0-9]){3}-([0-9]){2}$ Now, is there a way…
-
4
votes1
answer1202
viewsHow to ignore elements escaped in a rule in regular expression?
I’m wanting to do with regex (regular expression), for example (if it’s javascript): var str = '[abc\[0123\]] [efg\[987\]h] [olá \[mundo\]!] [foo [baz]]'; str.match(/\[(.*?)\]/g); Exit:…
-
4
votes2
answers282
viewsFilter string REGEX C#
I have a string that returns all the content of an html page. On this page, you have the following line: <input style="width: 2.3em;" id="nacional" value="3,48" type="text"> I need only the…
-
4
votes1
answer63
viewsRegex that captures date informed by user, typed in a sentence
If I have a phrase: "melhor 01/01/2016 - 05/01/2016" How can I retrieve the dates of this phrase using regex? thus: var data1="01/01/2016" , data2="05/01/2016"
-
4
votes2
answers78
views"Permissive" regular expression to detect extensions and allowed hosts
i have a list with some links https://www.exemplo.com/ https://www.exemplo.com/home/ https://www.exemplo.com/logo.png https://intranet.exemplo.com/ https://admin.exemplo.com/login…
-
4
votes1
answer290
viewsWhich regular expression would be more appropriate to validate a Cronjob expression?
I’m looking to learn a little bit more about regular expressions. I thought of a good exercise that will be validating whether a cronjob expression is correct or not. Therefore, the possible…
regexasked 8 years, 5 months ago Wallace Maxters 102,340 -
4
votes2
answers817
viewsCheck if string starts with number
I need to check if a string starts with numbers. I want to do this using Regex in c# public static class StringExtensao { public static bool ComecaComNumero(this string str) { if…
-
4
votes1
answer610
viewsREGEX password validation
I have a Validation problem and I cannot apply within a simple structure, 3 validations cannot have decreasing, increasing or repeated alphanumerics in the same password. For example: 00000000 ,…
-
4
votes1
answer134
viewsBulk Substitution in XML
Good morning! I have a program that check some signals, but in the code is indicated only which signal should appear, so I must apply the specific information that should be checked. But manually…
-
4
votes2
answers480
viewsSingle vs. Double Quotes in PHP Regex
whereas I own a path which I wish to verify with preg_match if it is the desired path, what is the difference between the two operations to follow? // Single quoted string…
-
4
votes2
answers1662
viewsApply filters to a Jtable
I have a table and in a JPANEL on top of it I created textFields and combobox with the intention of using them as filter. The method: tableRowSorter.setRowFilter(RowFilter.regexFilter("(?i)" +…
-
4
votes2
answers2530
viewsHow to remove all "/" occurrences from a string using Javascript
Hello, I’m having trouble applying a simple regex with Javascript. So: var str = "/Date(1421287200000-0200)/"; console.log(str.replace('/\//g','')); //não funciona, mesmo estando certo…
-
4
votes1
answer178
viewsHow does this regex work in js?
I found on the internet this regex in javascript that formats monetary values in R$: Number( 1450999 ) .toFixed( 2 ) .replace( '.', ',' ) .replace( /(\d)(?=(\d{3})+,)/g, "$1," ) // 1450999 ->…
-
4
votes1
answer490
viewsRegex in python Find() function
I need to use a regex in the function Find() in Python for example, if I use inside a loop : arq = open("arquivo.txt","rb") var = arq.readline() a = var.find("abc.*def") He will be looking at the…
-
4
votes1
answer211
viewsHow to use regex starting in the middle of the string?
I have a rather large string and would like to check if an excerpt of it house with a regex. The problem is that this stretch is in the middle of the string, in a very specific position. As I will…
-
4
votes4
answers388
viewsRegex to capture infinite groups in a URL by separating them by the bar
I wonder how I could do a regex to capture several groups as shown in the string below: /Controller/Action/Param1/Param2/Param3/... I want to capture "Controller", "Action", "Param1", "Param2",…
-
4
votes7
answers185
viewsCapture year outside the regex
I am working with a text file using the sublime I want to replace some strings where: I have several strings like this: EMISSAO="2016-04-18 00:00:00" I need a regex that captures where the year is…
-
4
votes1
answer93
viewsHow to capture only the first part of a text that fits in regex?
<END>Av. Dr. Walter Belian, nº 2.230, Distrito Industrial, João Pessoa-PB, com CNPJ nº 07.526.557/0013-43 e Inscrição Estadual nº 16.218.7157; (NR) II - Sergipe, localizada na Rodovia BR-101,…
-
4
votes4
answers14684
viewsJavascript Regular Expression for Phone with IDD
I’m having trouble understanding the logic of Regex, and I can’t find codes that make up the complete phone mask with IDD, DDD and phone with 8 and 9 digits with change of hyphen when typing…
-
4
votes1
answer195
viewsRegex for python float validation
r"[+-]? d*.? d+" This regex is accepting numbers with more than one point Ex: 12.23.43 and was not to accept...