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
answer43
viewsReturn CSS file classes using Regex and PHP
I have the Following CSS: .icon-a{ background:black; color:white; } .icon-b{ backgroundwhite; color:black; } .icon-c{ background:blue; color:yellow; } I wanted a PHP script that could read the CSS…
-
1
votes4
answers9178
viewsRegex to pick a text between <>
I’m trying to pick a word between <>. For example: Text: "Joao <[email protected]>" My regex should take [email protected], but it’s catching <[email protected]> The regex I’m using is…
-
1
votes1
answer262
viewsjquery inputmask does not accept quantifier in "Validator" function
I am trying to make a customAlias to use with jQuery Inputmask, but I am facing the following problem: My input: <input id="input-field-nome" data-inputmask="'alias':'customAlias'" type="text"…
-
1
votes1
answer355
viewsChecking browser and version with REGEX
I am working on a Vb.net MVC system and need to detect the browser and version. I will only use Chrome, and IE9+. I was wondering if I could simplify the verification structure using Regex. Below…
-
1
votes1
answer262
viewsValidate CNPJ countries Latin America
I’m doing a CNPJ validation of Latin American countries. I don’t really understand the Regex and would like help to validate the following rule: 3 digits, 6 Numbers (YYMMDD), 3 digits (like P&G…
regexasked 8 years, 10 months ago Junior Torres 427 -
1
votes1
answer189
views -
1
votes1
answer757
viewsTake content from a div and save to a regular expression array (PHP)
I wonder how I can take the contents of the div with class="x-product" and save in an array so I can manipulate them later. I tried that code but it didn’t work. <?php $url =…
-
1
votes4
answers1429
viewsHow to search for results in Mysql where a given field only has special characters?
I need to search in Mysql, lines where a given field, for example 'Name', is filled only with special characters or white spaces. I tried several REGEX for such but unsuccessful. Could someone help…
-
1
votes1
answer84
viewsHow to make a regex that accepts one line but not two?
I get lost doing any complex regex. I use the following code in java: Pattern pattern = Pattern.compile("tentativas de regex aki"); Matcher matcher = pattern.matcher(conteudo); while(matcher.find())…
-
1
votes1
answer26
views.htaccess detect string after Slash
I’m not getting htaccess to detect string or characters after / for example. I have this: foo.foo/xx/ and I wanted when this happened foo.foo/xx/whatever o . htaccess internally executes a php code…
-
1
votes3
answers9575
viewsAllow only letters, numbers and hyphen
How to validate a php string to contain only letters, numbers and hyphen ( - ) Thank you
-
1
votes1
answer790
viewsFormat file names using Regular Expression
I am trying to rename some files using Regular Expression, but I am stuck in a specific format. I have video files in this format: Yu.Yu.Hakusho Ep.001 - Death I need to format using regex to:…
regexasked 8 years, 7 months ago user28595 -
1
votes1
answer724
viewsHow to use Pattern to delimit a minimum number in an input text?
Hello, I need to define that the minimum number inserted in an input of type text is the number 5, I tried as follows: <input type="text" name="someName" id="someId" required="required"…
-
1
votes2
answers5842
viewsRegex to validate date yyyy/mm/dd?
I have tested several expressions, but I did not get the desired result. How can I validate the date for yyyy/mm/dd ?
-
1
votes1
answer44
viewsRegex to add a hierarchy level to all CSS rules
I don’t have much knowledge about regex (I don’t think anyone fully understands this) and would like to make a regular expression to change a CSS file by placing a hierarchy level (a class called…
-
1
votes1
answer245
viewsHow to include a regex in the parameters of an Express route?
In a project I’m doing I want to point a specific route to a controller. In a simple case of a route with parameters I would do so: app.get('/:lang/:activities/:activity',…
-
1
votes1
answer204
viewsSeparate items from a string using Regex
I need to separate the items of a string in an array using C# and Regex, could help me? The string is as follows: required|email|min:2|max:255 There are some rules I wanted to suit: Separate main…
-
1
votes3
answers18768
viewsRegular Expression - Numbers only, no space
I have the following regular expression '((?:[\d][\s]?){5}[\d])' and I’m testing her on https://regex101.com/. My problem is this: If I have that bit 'teste 123456 teste' she will return me only…
regexasked 8 years, 5 months ago Luis Medeiros 99 -
1
votes1
answer308
viewsRegular Expression, preg_match() and storage in an array
Hello. I have a .txt (Pastebin) which contains the log of the connected clients on a server openvpn and the format of each of the lines is the below: CLIENT_LIST orion-01889596000195…
-
1
votes2
answers96
viewsRegex works on online tester but does not work on my javascript site
Link to the site where I tested regex I test on the site and works correctly the goal is to have 2 numbers as coordinates 12.0,34.0 and receive the valid answer but I am receiving in my invalid log.…
-
1
votes1
answer353
viewsRegex - Regular Expression to get a text block
How would a regex capture the block of declosed variables in a Delphi unit ? The closest I’ve come to this is using this var[^=]*[^\)]; but without success. var Variavel1 : string; Variavel2,…
-
1
votes2
answers162
viewsRegex remove some elements from the style attribute
I need to keep just a few properties of the style attribute in tags present in a string of an html document, they will be placed in a Whitelist, everything else will be removed. In the example…
-
1
votes1
answer74
viewsValidate a Matcher
Good afternoon. I would like to know how to check whether the matcher found something. Because I am searching for information inside a PDF file and when it does not find anything I would like to…
-
1
votes1
answer632
viewsRegular expression of monetary value
Hello I have the following function function CarregarMascaras() { $('[data-mascara=numeroMonetario]').keyup(function () { this.value = this.value.replace(/[^0-9]+[^\,]?[^0-9]+/g, ''); }).on('paste',…
-
1
votes1
answer1470
viewsFind content within two html tags - Regex
I have an HTML page in a string variable. I need to search inside the H2 tags of every document if there is the word "Blog". I’m using the pregmatch but I can’t create the expression to find. You…
-
1
votes1
answer142
viewsNegation operator returns value that should be discarded
When using the negation operator, I want to get only the part of the text that does not contain the previously denied group. Using the expression ( ?<br\/?> ?)(Unit.), I get the following…
regexasked 8 years, 3 months ago Marcelo de Andrade 7,261 -
1
votes2
answers981
viewsModify xml in multiple files
Hello, Personal need to modify a value within an xml Node, the problem is that I need to do this in 1300 files at once, the value I look for inside the node can be any one, it does not make any…
-
1
votes1
answer279
viewsI need to create a regular expression to validate a Camelcase
Good morning to everyone, I hope you can help me. I need a regex or even an idea of how to insert a space for Camelcase expressions. In other words, insert a space for each uppercase letter of the…
-
1
votes1
answer77
viewsEscape from regex in php
local-config_form_settings-test To match the "test", I’m using this regex: (?<=config_form_settings-)([a-z0-9]+) I tested the regex here: https://regex101.com/ And it’s just the way I want it. In…
-
1
votes1
answer505
viewsRegular Expression Regex
I want to make patterns that way: [a-z]+[acentos] || [a-z]+[acentos]+[espaço]+[a-z]+[acentos] || [a-z]+[acentos]+[-]+[a-z]+[acentos] In order to be able to register a word, it is necessary to be…
-
1
votes1
answer243
viewsError with Php and Preg_match
I have the following line in a php file if(preg_match("!\oa!", $id)){ until a couple of months ago this worked normally but began to give this error Warning: preg_match() [Function.preg-match]:…
-
1
votes2
answers110
viewsProblem with regular expression in Asp.net with Angularjs(1)
On this site, I got this regex: @"^\(?\d{2}\)?[\s-]?[\s9]?\d{4}-?\d{4}$" Then I tried to adapt to my reality, my rule which is: Only accept digit(number) in the input. I’m not there those things…
-
1
votes1
answer1183
viewsHow to create Pattern (input mask) with jQuery Validation Plugin?
I need to create a input mask (Pattern) for the type CPF 000.000.000-00 and to CNPJ 00.000.000/0000-00 through the plugin jQuery Validation. What would be the regex to be creating this validation?…
-
1
votes1
answer60
viewsFind and replace string
I have this json returned by a webservice: spConfig[92769] = new…
-
1
votes2
answers89
viewsHow to make a regex capture a large variation of a term? (HOUSE, House)
It is as follows: since it has a term that I wish to capture, for example, "HOUSE", how to make a regex to capture many variations of this word, example: House, House, House, House, House, House...…
-
1
votes2
answers226
viewsHow to construct this regular expression?
I’m trying to build a regular expression and it’s a little difficult. I would like you to help me, and if possible explain how the computer works in relation to this expression that I am asking for.…
-
1
votes1
answer343
viewsCollecting links in a text file
I have a problem in my program where I have to get links in the entire text file. I used regex to collect the links, however, only a few lines are captured (the file has approximately 3500 lines)…
-
1
votes2
answers157
viewsRegular Expression
Regular Expression for password validation. I want it to be possible at least a minuscule letter, a capital letter, at least a number and special characters (/,_,-, ... ). Example: $regex =…
-
1
votes2
answers985
viewsHow to allow a regular expression of letters and numbers to accept cedilla
I need the regular expression to accept the key c cedilla. $('[name="txtEndereco"]').keyup(function () { this.value = this.value.replace(/[^a-zA-Z 0-9]+/g,''); });…
-
1
votes2
answers2447
viewsfill in right-to-left input
I need two input that I have in an app are filled from right to left... one of the inputs is real value (R$) the other is value in milliliter (ml), I am using a jquery mask (a Maskmoney works right…
-
1
votes1
answer197
viewsMount Regex to change string json
I have the following string, which will actually be treated as a json, stored in a column in the database in my SQL Server: {"PT":"adssadsadsd "asdada"","ES":"","FR":"","EN":""} How do I…
-
1
votes1
answer301
viewsHow to get link from any anchor using regular expression?
I use this code to capture links from a particular page: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch,…
-
1
votes3
answers175
viewsExclusion via regex
I have the following string: 2014-10-12 17:04:29.996 It’s a format timestamp and is wrong because after the hour there is the .996. To capture this stretch I used the regex : \d{4}-\d{2}-\d{2}…
-
1
votes3
answers753
viewsCPF Regex with Laravel
The system where I am doing maintenance has Cpfs registered in two ways, with and without score, due to a bad development start that did not impose a standard. The problem is that the CPF cannot…
-
1
votes1
answer81
viewsDoubt about Regular Expression
Good night to you all. I would like to know a regular expression for the following information: Numbering and title of a chapter. Example: INTRODUCTION number = 1. title = INTRODUCTION 1.1. GENERAL…
-
1
votes4
answers111
viewsGet content between tags [x] and [/x] with Regular Expression
My question is the following, I have the content below that comes from a table in a database and I would like to use a regular expression or if you have something better, to separate only the…
-
1
votes2
answers1793
viewsOnly get the first name, after space using Java
Good afternoon. I got the following String: "Carlos Ferreira da Silva" I wanted to take just the first name and ignore rest after the "space". Using regular expressions, how could I do that?…
-
1
votes1
answer108
viewsTake CSS link with Regex
Good morning guys, when pulling the html of the entire page in string it also brings some reference links: <link href="~/Content/item/item.min.css" rel="stylesheet" /> I already removed the…
-
1
votes1
answer47
viewsVirtualhost configuration
I have a question in the configuration of VirtualHost, I have an application that has redirect to multiple cores ex: meusite.com.br/app/go meusite.com.br/app/rj When access meusite.com.br/app, it…
-
1
votes1
answer3392
viewsDelete blank lines
I have a text that has a structure like this: AJUSTE_ESTOQUE AJUSTE_PRODUCAO AJUSTE_QUALIDADE AMOSTRA I made a regex (^\s*$) to locate these blank lines, how can I remove them so that each word is…