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
answer642
viewsGet snippet of a String with regular expression in JS
Well, what I need to do is receive a string via input, and "get" a certain value within such a string. Below I show an example to better illustrate the situation: <iframe width="560" height="315"…
-
2
votes1
answer246
viewsRegular Expression that checks the presence of a repeating Pattern
How do I make a regular expression that this one has to repeat exactly one tot of times? For example, I would like to check if a line in a file contains this |1_CHAR exactly 8 times. By the way, it…
-
2
votes1
answer83
viewsHow do I create a String template and whenever the user passes something different report the error?
I need a String template that starts with letter, has no space, accepts numbers, is case sensitive, (uppercase and minuscule) and does not accept special characters or accents, (will be the name of…
-
2
votes2
answers127
viewsRegular expression to create a line of a cock game (tic-tac-toe)
I’m trying to use a Pattern to find a certain line in a file, but it’s not working. This is my Pattern: row = re.compile(r"(|\s[OX\s]\s{3}|)") With this I want to find basically this Pattern: | | O…
-
2
votes2
answers947
viewsUsing Regex to pick up a certain value
I am using this "string?" in regex ^\/(.*)\w+$ It detects values that start like this: /STRINGQUALQUER would like to catch the STRINGQUALQUER, what code do I use? I use jQuery.…
-
2
votes3
answers133
viewsRegex capturing it all
I’m in trouble with a Regex, she’s not just taking it 1 de 8 as I wish, she’s getting way beyond this, see : https://www.regex101.com/r/eX6bC9/1 That’s the string I’m trying to match: <span…
-
2
votes3
answers2361
viewsRemove URL parameter with Javascript
I am creating a functionality for a system and I came across the need to manipulate URL parameters in this way I would like to know, how to delete a certain parameter from the URL? Follow a clearer…
-
2
votes2
answers227
viewsHow to replace Regexp in editable div using Javascript?
I have a div editable where I capture all text within it. Hence I want in each occurrence of certain word this word is replaced by another. Very simple. The code I tried did not work. It itself…
-
2
votes3
answers322
viewsPut in array strings according to a regular expression
I would like to make an array containing strings in this format: [Texto com acento espaço e números 99] Example, if I have this string: var texto = "Eu quero comprar [qtdOvos] e [qtdFrutas] somando…
-
2
votes1
answer174
viewsHow to find exact Regexp and do this using constructor syntax?
I have an algorithm that takes several complete file paths and checks if each of them is 'forbidden' by the server. The var s of for is related to each of these paths and the sets is an array with…
-
2
votes1
answer1229
viewsRegular expression for href and www/https/http links
Good morning, I have 2 regular expressions, where one serves to get the URL of any href, and another that I need to arrange that would just be to get the URL’s that are not inside a href, ie, only…
-
2
votes2
answers1207
viewsReplace values inside string
How do I replace values within a string? To string will be something like: gabriel = 1.73,derp = 1.80, Take into account that this structure is: nome = altura, nome = altura,. In case, I want to…
-
2
votes2
answers798
viewsConvert a text link to a href link
I have a site where I have an editor (html) only q sometimes instead of using the button to post the link people paste the link and it is in text so I am a regular expression to convert the text to…
-
2
votes2
answers1528
viewsHow to create validation with special characters
I would like to know how to create a validation with preg_macth() where you have to accept these characters from the keyboard: /^([a-zA-Z0-9]{6,40})$/ `~!@#$%^&*()_-+={}[]\|:;"'<>,.?/…
-
2
votes1
answer72
viewsUse Regex on switch in jQuery
Guys, I have a question here and I don’t know if it’s possible to do what I want (I think so). The question is, I have a switch(link) and follow example of cases (example link): marry…
-
2
votes1
answer403
viewsindex with regular expression using variable
I use the index to check if a string contains a certain text. However, this is case sensitive and accents sensitive. Would there be some way for example I find these records in case to enter in the…
-
2
votes1
answer120
viewsWhen fetching the attribute of a tag, it is bringing the value of another
function returnvalue($namearr,$exec){ $result=""; foreach($namearr as $arr => $value) { $regex = '<.* name="'. $value .'".*>'; if (preg_match($regex,$exec,$result1) === false) { $result4="…
-
2
votes1
answer231
viewsDelete letters before after a number
Hello, I have a string (var test), and would like to perform some operations on it. The desired result is a number, preceded by or of the letter p, s, or ps (NAY sp) (ex: ps1), and a number followed…
-
2
votes2
answers468
viewsRegular expression problem in . htaccess
I have the following rules in my file .htaccess: RewriteRule ^first-login/([a-zA-Z0-9]+)$ ./first-login.php?userKey=$1&step=1 RewriteRule ^first-login/([a-zA-Z0-9]+)?([0-9]+)$…
-
2
votes1
answer49
viewsWhy is my regex not working as expected?
I really have difficulty assembling regular expressions, mainly by varying their behavior in each language. I am translating a Java code for JS, in which the regular expression is…
-
2
votes1
answer184
viewsWhy is my variable null?
I am translating a function from Java to JS, the logic remains the same but the results are different. In the regular expression test, returns match when I test 40kb but when compiling the code I…
-
2
votes2
answers220
viewspreg_replace with Regex to add a tag
Does anyone know how to make regex select the phrase and add a tag? <li> <p>b) texto muito longo;</p> </li> $FechasemClassAlinea =…
-
2
votes1
answer333
viewsSelect all elements of an array in a variable with Regex in PHP
I would like to do a regex to apply a class to each row with Roman numbers, the regex would be? /(<li>\s*<p>$romanos\)_\-_/ ? The documents are like this: <li> <p>I -…
-
2
votes1
answer160
viewsExtract HTML value
I get the html and a part of it from where I need to extract the data and this one <td class="address-list-item"> NOme silva <div class="modal-content" style="display:none;"> <div…
-
2
votes2
answers254
viewsDoubt about a specific regular expression in Javascript
Using a regular expression (regex), I would like to know how to validate such conditions: 0-9 / * - + ( ) pi root But in addition to allowing numbers and characters, I would like the expression to…
-
2
votes1
answer129
viewsHow to get only a part of a string from a pattern?
I have a string in Lua language. I want to get only the part of filename through the match (403.htm.en). Example: var=[[Content-Disposition: attachment; filename="403.htm.en" Content-Type:…
-
2
votes1
answer701
viewsCapture double quote content with recursion with Regex
I need to capture double quotes with Regex in PHP. I tried using line-breaking recursiveness in several ways, but to no avail. I’ve combed through several topics and researched how to do that, but…
-
2
votes1
answer65
viewsValidate regular expression categories
I would like to know how to validate categories with regular expressions. So I have a list of categories separated by comma. Each word must have a maximum of 20 characters, I need to validate every…
-
2
votes2
answers958
viewspreg_split to separate words, but ignoring some
I need a regular expression that splits a string, more specifically a full name of a person, and transforms it into an array of words. $string = "Wallace de Souza Vizerra"; $array =…
-
2
votes1
answer154
viewsValidate Google Site Verification URL with Regex
With $_SERVER['REQUEST_URI'] I capture the following address below! /google9f7804416f93fdd6b.html I need to perform a validation with ER, the function has to recognize the word Google the parâmetros…
-
2
votes1
answer1235
viewsValidate URL Regular expression
I would like to know the following, I have a regular expression to validate Urls, but I would like it to not only validate the URL, but release it if the URL is empty or empty: I believe that was…
-
2
votes2
answers98
viewsUse the number of characters obtained in a regular expression sentence in string substitution
I am doing a Markdown parser as part of a study on regular expressions, and I would like to use the amount of characters obtained in an excerpt of the expression, as a basis for string substitution,…
javascript regex parser ecmascript-6 ecmascript-5asked 9 years, 3 months ago Daniel de Andrade Varela 267 -
2
votes3
answers6138
viewsMount Regex to validate password
someone would know to set up a regex to validate numerical and alphabetic sequences of at least 4 digits, like : 1111/1234/abcd/4321/dcba?
-
2
votes1
answer159
viewsRegex - Very high replace process time
Recently after developing a process, I saw that this was taking exorbitant 5~6min to be executed, something that should take at most 2s, so I started debugging the code with timers to know what…
-
2
votes1
answer209
viewsHow to construct the regular expression for the case?
I need to create an expression for the following case of a code field: No maximum number of characters The first digit should only be numbers [0-9] The code is composed of alphanumeric digits and…
regexasked 9 years, 1 month ago Marcelo de Andrade 7,261 -
2
votes1
answer79
viewsProblem with Regular Expression
I have this regular expression in php that should find the pattern in a file name. Example: dge_ANEXO_II_F_TJ[1].pdf But I can’t make it work. Can someone help me?…
-
2
votes1
answer98
viewsRegular Expression
I have an application that reads a string and needs to detect parameters contained in the string. The parameter has the following pattern <<<.texto>>> (< and > are part of…
-
2
votes2
answers1159
viewsHow to limit the number of houses before the comma in a regular expression?
I am using this expression to not let the user type point before any number and limiting 2 houses after the comma, but I also needed to limit 5 houses before the comma, the way it is I can enter as…
-
2
votes1
answer108
viewsRegex does not work on Chrome
I have the following script in which I use a jquery to validate a regular expression that matches the filenames for upload: $(document).on('change', "input[type='file']", function() { var validaFile…
-
2
votes1
answer247
viewsHTACCESS - Directory deletion condition
Good night! I am with the following scenario in an application: I’m redirecting all requests to my index.php and treating URL’s through the application: RewriteCond %{REQUEST_URI} !admin RewriteCond…
-
2
votes2
answers162
viewsAutomatic line break with regex
I have the following string: $var = "Saudi Arabia U23 x South Korea U23"; I want to divide the names that are separated by "x", I did the following: $arr = preg_split('/[v|x]/', $var); I used "V e…
-
2
votes1
answer627
viewsGeneric Parameter Friendly URL . htaccess
I’d like to ride a URL user-friendly with generic parameters, ie that receive any parameter in any quantity or file. Today I rode the .htaccess so that the file name becomes the URL. File I am…
-
2
votes3
answers211
viewsRegex to ignore invalid file names
Hello, I’m trying to add a regex to app.yaml to ignore files with strange names on Google App Engine, but it’s not working. My regular expression: skip_files: - [.\\~#%&*{}:<>?|\"-!] I’m…
-
2
votes2
answers187
viewsHow would a regular expression find an attribute html + attribute value?
I want to give a find/replace in all the attributes html "data-placeholder" and its values, of my application, through the search of Visual Studio. For this I need to assemble a regular expression…
-
2
votes1
answer205
viewsDoubts about using Contains with Regex in C#
I would like to use in a code in C# the method Contains , but instead of spending one string literal, ie a specific word, pass a pattern or a regular expression as parameter. For example: Instead of…
-
2
votes1
answer931
viewsHow to do regular expression to accept words and then 2 numbers with jQuery, no special characters?
Hello, everyone. Next, I am making a regular expression to accept the following: 02 word. Word and numbers, not just numbers. I’m using this code: $(".inputNomeTurma").keyup(function() { var valor =…
-
2
votes2
answers253
viewsRegex - Regular Expression
I wonder why the regular expressions I’ve written aren’t giving match (marrying) correctly. The expressions are as follows:: User name that must be unique and cannot contain special characters…
-
2
votes3
answers1441
viewsPHP Regex Catch the html tag
I would like to ask for help to make a regex that separates the values of this string: <table>|<tr>[<td>#VALOR#</td>]</tr>|</table> I would need the regex to…
-
2
votes1
answer170
viewsRegex, valid if there are specific words in any order
For me it is always better to exemplify the cases of regex. Look at this: Palavra1- Valid Word2- Valid Palavra1 Word2- Valid Word2 Palavra1- Valid Palavra1 Palavra1- Invalidity Word2 Word2-…
regexasked 8 years, 6 months ago Rodrigo Santiago 1,822 -
2
votes4
answers1228
viewsAlternative to sed with Powershell
On UNIX I would do something like this: sed -n '/início/,/fim/ p' < arquivo.txt In Windows we have Powershell, how do you do it with it?