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
-
3
votes4
answers1038
viewsHow to create a regex to filter and delete files with a particular chunk in the name
I’m trying to figure out a way to delete files that windows duplicates when making multiple copies. I was able to do something by creating the code below: import java.util.*; import java.io.*;…
-
3
votes1
answer198
viewsGetting whole words with Regexp in Jquery
$.fn.wrapInTag = function(opts) { var tag = opts.tag || 'strong', words = opts.words || [], regex = RegExp(words.join('|'), 'gi'), replacement = '<' + tag + '>$&</' + tag + '>';…
-
3
votes2
answers104
viewsReceive only number in money field
I’m looking for a td with jQuery. var linhaTr = $("tbody").find("tr:first-child"); var tamanhoTd = linhaTr.find("td:nth-child(2)").text(); and he returns me for example R$ 5,00. But I need to get…
-
3
votes2
answers435
viewsJavascript regular expression to validate user name size
I need a regular Javascript expression that meets the following rules: Between 2 and 255 characters In low box (Lower case) Contain only alphanumerics, underline (_), dot (.) or hyphen (-).…
-
3
votes3
answers1157
viewsRegex check IP
I am implementing a regex to accept IP address, for this I am using a Mask in the textEdit component of Devexpress, however when I leave the field blank or with only one filled part locks all other…
-
3
votes1
answer322
viewsHow to search for tags using Regular Expression?
I would like to create a regular expression that searches for tags: <b>, <p>, <i> How would you do that in regular expression?
-
3
votes2
answers1971
viewsHow to capture string between square brackets
I need to capture strings between brackets within a string. I found a solution that doesn’t solve my problem completely: \\[(.*?)\\] Use like this: Matcher mat =…
-
3
votes1
answer3696
viewsText field formatting for PIS/PASEP
Actually it’s not a question but a help. I’ve been researching PIS/PASEP mask and I couldn’t find so it was the way to implement. I’ll put the answer below. Hugs.
-
3
votes3
answers610
viewsRegular expression for email in C++
I have the following regular expression in a C++ format validation function using regex, but it is validating non-standard formats that I want. b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}b\\.[A-Z]{2,4}b…
-
3
votes1
answer105
viewsRemove string numeric sequence
I have the following problem, I believe I can solve it with regular expressions, but I am terrible with the same. Let’s say I have a string that way: CONECTOR BNC FEMEA + F MACHO 024267 or so PLUG…
-
3
votes3
answers524
viewsRegex in javascript for partial match in URL
I need to write a javascript regex that contains a specific piece of URL, but I’m not able to, mainly because it’s a url with "/". Example: Any "like" or partial match to "www.url.com/foo"…
-
3
votes2
answers102
viewsRegex lookbehind
I need to write a regex to parse an excerpt from a field of the Swift message, so I’m using loockbehind. In the example below I have the two strings I need from the 12 positions of Bic. In the first…
-
3
votes1
answer156
viewsPHP regex recursive
I have to validate the syntax of expressions like these: (ind(10)+15)-10 1000-(perg(25)*2) 25/var(1) 12*2-(58+1)/5 Ind, Perg and var are functions. I’m trying to solve it this way: $var =…
-
3
votes1
answer89
viewsHow to find a string based on a group of regular expressions
I’m trying to create a Template Engine in PHP for study purposes. Suppose I have the following array: $regexList = [ 'varPattern' => '/{{\s*\$(.*?)\s*}}/', 'loopPattern' =>…
-
3
votes2
answers766
viewsHow to create a regular expression to validate only cell phone number?
I made that expression, but I don’t know if it’s in today’s standards "/^[1-9]{2}\s?9\s?\d{8}$/"
-
3
votes1
answer343
viewsWhat does this htaccess regex do?
I have this regex: RewriteRule ^www\/login\/?$ login/ [L,NC,R] What does she do?
-
3
votes2
answers225
viewsRegexp extract value
I have the following strings: "The.Office.US. S{SE}E{EP}.the.Dundies.720p.srt" "The Office [{SE}. {EP}] The Fight.srt" This string is a "template" of a file name, the files will be in the following…
-
3
votes3
answers2728
viewsHow to select this piece of text in Regex
I have the following text example: 1.1.1.1.1. Test. Test 1. 1.1.1.1. Testing 1. Testing I would like to select the 1. of all but until the test. I used the following regex: ([0-9]. ) the problem is…
regexasked 7 years, 5 months ago Matheus Machado 33 -
3
votes1
answer118
viewsHow to create a function that validates if there is a Mysql function in a given string?
I am looking for a function that identifies (return true) if there is a Mysql function in a string. These would be some examples of possibility of input to function. <?php $randomstrings = […
-
3
votes1
answer111
viewsREGEX - How to capture blocks of CASE WHEN ... END
Good morning, you guys. I’m trying to make a regex to capture blocks of CASE WHEN ... END. So that string: iduser + CaSe WhEn ("end") = 0 THEN 'CASE WHEN' ELSE ' END ' END + sum(iduser ) + CASE WHEN…
-
3
votes1
answer205
viewsHow to create groups in regex to validate password criteria in Elixir?
I need to validate the criteria in a password: It must contain at least one capital letter. At least one tiny At least one number The size should be between 6 and 32 characters May not have any…
-
3
votes4
answers318
viewsHow to get the last segment of the path?
URLs de exemplo: content/edit content/edit/ content/edit?q= content/edit/?q= I tried to make the code but it always fails when the url does not have "/" or "?" and if there is "/?" at the end. The…
-
3
votes2
answers13204
viewsWhat is regex to validate only points, numbers and commas?
What is the regex to validate only points, numbers and commas?
-
3
votes1
answer74
viewsWhy does the Matcher class not return the number of groups correctly?
After the question "What is the difference in use between the Matcher() and find() methods?", I kept testing this class to understand its functioning, but I came across a strange behavior. When…
-
3
votes2
answers334
viewsRegex validating only normal and leap years in C++
I was trying to validate leap years using regex in C++. If the user type 28/02/1900, it would return valid. But if the same type 29/02/1900, he would return error. Searching, I found this regex that…
-
3
votes2
answers343
viewsAdding strings from a regular expression
Good evening, I would like to find a way to add two strings within a regular expression using php. Ex: $texto = " |5,00|7,00|| |10,00|2,00|| |3,00|30,00||"; ...('/\|(.*)\|(.*)\|/',…
-
3
votes2
answers2759
viewsHow to make Regex accept only numbers?
How do I use the preg_match that only accept numbers? And that these numbers can also start with zero? function formatacao_cpf_func(){ $regular = "/^[0-9]*$/"; if(preg_match($regular,…
-
3
votes0
answers79
viewsComplete expression
Well, I have something like this: /^perfil[\/]?([0-9]{3})?[\/]?([a-z]{4,5})?[\/]?/i And I need to create a function that by receiving the right information turns this into perfil/431/abcd/…
-
3
votes1
answer280
viewsBackslash in Regular Expression
was studying java and the course instructor left a challenge to validate an email using regular expressions. I searched the regex API documentation...for the Pattern part.. The problem is that I…
-
3
votes3
answers2037
viewsRegex to validate certain date format
I was modifying a regex for a program in c++ that would validate the following date input form 29/feb/2000. Currently she was only accepting 29/02/2000 or 30/03/2017. I tried to add for the other…
-
3
votes1
answer174
viewsIs it possible to remove the first sequence of the last letter of the regex?
I need help on something very specific, which involves good interpretation, is the following, I need to inform a word on regex example nt the last letter that would be t was extended to the first…
-
3
votes2
answers198
viewsForcing backreference in regex
These days ago I asked here about a regex that validates dates and how to force the separators to regex validated the following format: dd/mm/yyyy So based on it was trying to force the separators…
-
3
votes2
answers677
viewsJava regex help - comma-separated sequence of numbers
I’m breaking my head to put together a regular expression that validates String: /aluno/1/Teste dos Testes/1,2,3 String reg = "/aluno/[0-9]+/[^0-9]+/......." I’m having trouble validating last field…
-
3
votes1
answer213
viewsString postgresql manipulation?
I’d like to manipulate a String with regexp_replace as follows: String to manipulate: 'TESTE <<TESTE1>> TESTE <<TESTE2>>' String after function: 'TESTE TESTE' I tried it this…
-
3
votes2
answers648
viewsIgnore scoring in a sequence of numbers using Regex with Java
I have the following input: Fatura Cliente: 1.7852964.34 CPF/CNPJ: 09022317000222 I need to take only the "Customer Invoice" numbers, ignoring scores, returning only 1785296434, for this I am using…
-
3
votes2
answers117
viewsString match does not work with 1 character
I have the following obstacle: var myString = "c/q/1"; var match = myString.match(/c\/q\/([a-zA-Z0-9-].+)/); However match returns as null, already in the following example: var myString =…
-
3
votes2
answers660
viewsHow to pick a value between brackets in the string?
I have a string that will vary the values, I need to get the values inside the [], {"time_zones":[]} In case it would be empty, it may be filled: {"time_zones":[teste]} I’m trying to do it like this…
-
3
votes0
answers789
viewsRegular expression in Laravel
I’m not very good at regex but using the site https://regex101.com I was able to generate an expression that accepts: Do not accept special characters Can have up to 5 words separated by whitespace…
-
3
votes3
answers396
viewsHow to write a Regular Expression to find a paragraph?
What is the correct way to write a Regular Expression to find a paragraph? // Expressão Regular var minhaExpressao = /<p>.*</p>/; How can I correct this variable?…
-
3
votes4
answers2332
viewsRegex to pick word between two words or "/"
Someone can help me, I would just take the word between resourceGroups and providers and assign to a variable in javascript.…
-
3
votes2
answers327
viewsExact number of times a given character must repeat Regex
Hello, I’m with an exercise in formal languages, of which we work with Regex, the exercise consists in validating a chain that has exactly four 1s, for example: chain 1: 0110101000 - valid; jail 2:…
-
3
votes3
answers277
viewsUsing regular expressions with square brackets
Greetings, I have to remove any occurrence of texts between brackets. As for example: Ex.: [Text in square brackets] Text out of square brackets. Output would be: "Text out of square brackets"; I…
-
3
votes1
answer749
viewsRegular expression that accepts letters, numbers and underline
How do I make the ER below accept letters, numbers and underline, and continue not allowing the other characters? preg_match('/[^a-z\d]/', $_POST['login'])
-
3
votes4
answers717
viewsIn a sentence, how to know which word has the least characters?
In a sentence, how to know which word has the least characters? What I did was turn the string into an array, but I could only return the smallest when it comes to an array of numbers, using…
-
3
votes1
answer151
viewsSplit per point with exceptions
I have the following regex: (?!…
-
3
votes1
answer277
viewsDoubt Regex functionality - Java
Could someone explain to me what this Regex allows? private static final String MAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";…
-
3
votes1
answer39
viewsSimulate _GET php in string
I have a simulate string to: <li><a title="string" href="http://geting.com/?v=123?t=abc">Opção 1</a></li> I’d like something to take the parameter ?v=, just him, just like…
-
3
votes1
answer145
viewsReturn block-defined substring in Python on first occurrence
In python, I am trying to capture a block-defined substring, however the word "blocks" repeats in the text and I would like to get the substring up to the first occurrence of this. In this example…
-
3
votes1
answer135
viewsRegex - Take format without strings around
I’m trying to do a regex to get Slack formatting. Ex.: *a* => Take it to make bold An initial regex I did was: /\*(.*?)\*/g The problem: Can’t have anything around the string(No character stuck…
-
3
votes2
answers131
viewsRegex to extract string content
Good evening, everyone, Thank you for visiting and proposing to help me. I’m terrible at regex so I’ve come to ask for your help. I have the following string that can also vary as example:…