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
answer336
viewsFilter elements with Radiobutton in HTML and JS and Regex
I have the following problem. I have 3 elements label and I want, as the option radiobutton chosen to filter them. The problem is that when I want to filter by the name that ends in -Ivo it does not…
-
1
votes2
answers2425
viewsValidate Name Form
I have a question with validation of Html5, I have little knowledge with regex need to validate a form that get only: Uppercase and minuscule letters, with accents and etc; Whitespace; Can’t accept…
-
1
votes1
answer2149
viewsError Delimiter must not be alphanumeric or backslash
Good afternoon, stackoverflow crew. Is there a date in an array? I’ve been trying, using it like this: for($i = 0; $i < count($array); $i++){ if(preg_match( "\d{1,2}/\d{1,2}/\d{4}$" , $array[$i]…
-
1
votes1
answer203
viewsSearch with REGEX in VI
I have a regex that is valid according to the test site https://regex101.com/ , but in the vi she does not work: 2017\/04\/26 12:24:(.*)(89418644) Follow an example that this REGEX should marry:…
-
1
votes1
answer369
viewsHow to create a regex to remove lines with #?
I’m starting with regex now so I’m not very good yet with expressions, assuming I have the following variable: $foo = " #01 = linha comentada; 02 = valor para ser interpretado; #03 = outra linha…
-
1
votes2
answers351
viewsUse of Uniq
I have been researching without much success, something that in theory I believe is quite simple, however I did not find the correct command. I have a LOG file with a lot of information, but certain…
-
1
votes0
answers769
viewsRemove accents and symbols with regex
I need to remove the accents and replace the symbol & of that string: "Industry and Trade of manufactured products & aggregates, wells, manufactured and 1º ...", but it doesn’t work properly…
-
1
votes2
answers156
viewsHow to use preg_match_all in this excerpt?
<div> <span class="dark_text">Type:</span> <a href="https://myanimelist.net/topanime.php?type=var1">var2</a></div>~ I need to use preg_match_all to find the…
-
1
votes1
answer349
viewsRegular Expression that makes SQL Injection impossible
I’m looking for some way to avoid SQL Injection in the system I’m developing. Is there any regular expression that perceives the attempt of a possible SQL Injection attempt? Do you know any other…
-
1
votes1
answer26
viewsHelp with Regex in VB.Net
I’m trying to mount an expression to run in VB.Net that finds in the contents of a file the text GO. Text is always on a new line and may or may not contain spaces or tabs. I’ve come to the…
-
1
votes2
answers485
viewsFind and remove words from multiple arrays
I have some arrays that come from the database, and would like to remove word occurrences in them, for example the string in $title $title = "Eles foram com José procurar alguma coisa"; $bad_words =…
-
1
votes3
answers200
viewsHow to pick up parts of a text in php
How to pick the text apart "name":"ASUS p/ Intel LGA 1151 ATX ROG STRIX Z270E GAMING,DDR4,Aura Sync, Audio Gamer, Intel Network, SLI/CFX, Wi-Fi, USB 3.1 Front,HDMI/DP" and "price":1095.9 remembering…
-
1
votes1
answer151
viewsCapture all phones from a text file
I have a log records in html, and would like to capture all the phone numbers, both fixed and mobile that are scattered throughout the file, I use the following regular expression currently:…
-
1
votes1
answer37
viewsRegex - Recovering Property from Pre-formatted File
The idea is to develop a tool that selects fields from a pre-formatted file according to a specific schema: Schema: 1. [Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris efficitur…
regexasked 7 years, 5 months ago Vinicius De Paula 13 -
1
votes1
answer423
viewsImplementing Regular expression in Java
I need to make a program that reads a file and can count how many classes and methods there are. The reading and separation part by line I have done, I need to identify class and method. I am…
-
1
votes1
answer495
viewsRegular expression to validate urls
I have a web crawler that picks up links from websites,. I wanted a regular expression that matches the found links. And only links like these would pass.…
regexasked 7 years, 4 months ago Jeferson Mota 13 -
1
votes1
answer294
viewswant to do a phone validation more how do I validate the dash also if the user puts?
This is what I’ve got so far: public static function ValidaFone($RegeEx) { $RegeEx = preg_match('/^[0-9]{9,11,13}$/',$RegeEx); ........code..... }
-
1
votes2
answers152
viewsHow to cut a suffix from an expression in bash (egrep/sed/etc)
I’m making a script that works with directories that have suffixes defined and separated by "." for example "folder.teste.git" or "things.var" and would like to take as variable only the prefix…
-
1
votes1
answer189
viewsUser-friendly URL with htaccess pointing
My site is in a subfolder, I want the path to work independently of what I enter in the name of it, for example: www.meudominio.com.br/something/index.php…
-
1
votes1
answer62
viewsReplacement with sed
I have to replace some files and I’m not able to write an expression that works. I have this text at the beginning of each line: NF3-9-16S_S9_1456|M02255:210:000000000-B9K3P:1:1101:14397:18152…
-
1
votes1
answer640
viewsValidate and capture sequence of numbers
I have this string: 16-8-10-20-30-65 The numbers are random and this is just one example. I need a regular expression that validates that sequence, captures all numbers before 65, including minus…
regexasked 7 years, 4 months ago Vítor Martins 527 -
1
votes2
answers3290
viewsCapitalize the first letter of each word
I want to standardize what the user typed in edittext by capitalizing the first letter of each word and the rest lower case. How do I do this? The part that arrow the variables in the model class…
-
1
votes1
answer188
viewsValidating extensions of regex files in c++
personnel I made a function to validate extensions of files using the regex of c++ however it is validating extensions outside the regex I tried to do something to change it but could not get anyone…
-
1
votes1
answer32
viewsCheck occurrence in REGEX for php files
In php, I have to open a system file and check if after occurrence 10 of a char in the case ";" what is the content right after it. example: TPD;62384;P;;;;N;62308;N;;C;N;N;;F;02 what would be the…
-
1
votes1
answer41
viewsIncrement content found by regex and increment with other strings
I need more help with regex, how do I find in a text a certain pattern and include something next to the string you found. EX: "programacao": "11h Abertura – Som Mecânico 12h30 Lino e Orquestra…
-
1
votes0
answers38
viewsHow do I remove 3 special characters in a string variable, using regex?
Language used is c#, how do I remove 3 special characters in a string variable, using regex? example: (11) 2134-2135 expected result: 112132135…
-
1
votes1
answer112
viewsReturn regular expression value
I have the following string: [11:36:19] Touched down at -56 fpm, gear lever: down, pitch: 3, roll: level, 116 kts And I’m trying a regular expression to get the value 116 kts, where the string…
-
1
votes2
answers660
viewsA regular expression to detect acronyms of Brazilian highways
I’m trying to detect if a particular address corresponds to a Brazilian highway. For example, br-101 corresponds. My initial plan was to list the state acronyms (mg, sp, Rn ...) plus the br acronym,…
-
1
votes1
answer436
viewsCapture groups where a specific word appears with Regex
I have the following situation: text_1 = O cachorro correu com o gato text_2 = O carro passou e o cachorro foi atrás text_3 = Sempre que chego em casa meu cachorro pula em mim text_4 = Ele foi…
-
1
votes2
answers2522
viewsRegular expression for Telephones only with numbers and DDD C#
I would like a help to create a regular expression in C# that validates number of phones with DDD but no dots and dashes, only numbers. Would be in XX12345678 and XX 123456789 format.
-
1
votes2
answers421
viewsRegular Expression to capture after last bar
I have the following URL: ("file:///home/pasta/pasta/img/intro-bg.jpg") I wonder what regular expression I can use to capture only the intro-bg.jpg If anyone can help me, I’d appreciate it.…
-
1
votes0
answers345
viewsHow to block special characters coming from a "Paste"?
I have the following problem, there is a validation being made that way: $(document).ready(function(){ $(this).on("paste", "#email", function(event) { var $obj = $(this); setTimeout(function() { var…
-
1
votes2
answers6439
viewsHow to make a regular expression that finds a name and then looks for a character?
I was analyzing an extensive html code that basically contains this format: <span id="mensagem" class="topo">Classes e comandos</span> The problem is that the amount of arguments within…
-
1
votes1
answer213
viewsRule conflict in . htaccess
I am facing an error with . htaccess file and I am unable to resolve, is the following: I have the following rule: RewriteRule ^([^\.]+)$ $1.php [NC,L] This rule aims to ignore the . php extension…
-
1
votes1
answer167
viewsRegex Regular Expression - Include parentheses instead of quotation marks
How to exchange quotation marks for a tag? working to convert (*. dml ->Delphi form) where something that was like text becomes a list (stringlist). Text Example: CommandText = 'SELECT * FROM…
regexasked 7 years ago Karl Heinz Fischer 11 -
1
votes1
answer530
viewsCapture digit between parentheses
I have several types of texts, such as: $ticker="08.070.838/0001-63.offset(1)". I want to capture the text and the digit, if any, which is in parentheses to turn it into the form…
-
1
votes1
answer183
viewsRegex to validate mime type
What would be the regex to validate this mime types only image/bmp image/gif image/x-icon image/pjpeg image/jpeg image/png I want to upload an image system only, in the case of this mime types:…
-
1
votes1
answer65
viewsProblem with regex for Android Useragent
I’m trying to create a regex ( to use in PHP ) that can match the groups correctly and extract the information I need. In this case is to get information from android useragent. When the useragent…
-
1
votes2
answers107
viewsEstimating the response time of a server using Python or regex
I created a virtualized environment with an Apache server (running in Debian) and several attacking machines running Debian as well. Vmware Workstation was used. Server IP: 192.168.91.5 I have dump…
-
1
votes1
answer76
viewsRegex Custom Creation
Hello, I know very little about regex and need to create one that validates the result of a Barcode, I’ve used several sites, but since I have no knowledge I can not do, someone knows how to create…
-
1
votes2
answers193
viewsBlock of txt with Regex
Guys how do I pick up block by block of a txt with this format ? I have to get it by the last date. Sometimes there are two dates in each block AAAAAAAAAA AAAAAAAAAAA - AAAAAAAAAAAAA…
-
1
votes3
answers158
viewsHow do I marry this range of elements?
How do I pick up a text between these two elements, for example: a) texto <br /> texto texto texto <br /> I’d like to take what’s between a) and the <br /> of the end, only the…
-
1
votes2
answers72
viewsWhen I put b on Pattern.Compiler it returns find as false
When I put b in pattern.compiler he returns the matcher.find as false, because he can’t even find a pattern precisely because of the b. Following the code I use: final Pattern py =…
-
1
votes1
answer819
viewsPython - Dividing words delimited by blank space or square bracket
I have a string with several words inside, some words are separated by space, but some are compound words and are protected by square brackets. EX: string = "Goiânia Vitória Brasília [Campo Grande]…
-
1
votes1
answer80
viewsSearch file via file_exists with partial name
I need to verify the existence of a file in two domains. However, the file format that is saved in the database does not match the one saved on the server, due to a lag of a few seconds (the file…
-
1
votes1
answer45
viewsEquivalent of . test() (js) in php
In Javascript, we have the function test(), for example: /Test \[(\d+)\]/gi.test(string); // Pode retornar true ou false. php has some similar function?…
-
1
votes2
answers384
viewsHow to create a regular expression
I have the following div with information <div class="endereco-item"> <h2 class="azulclaro identify">Casa</h2> <div class="entrelinha_0"></div> <div…
-
1
votes1
answer146
viewsFlag at command line bash shell
I’m trying to put a flag that can sort or shuffle output, but I could only do that in code and intended it to work when you put the flag in the command to run the file, for example. /bash.sh -r.…
-
1
votes2
answers1127
viewsRegex only at first occurrence
I’m wearing the sublime and would like to do a mass replace. My texts are in this pattern: ABC ("Teste regex I would like to remove the space after the ABC and it should stay that way: ABC("Teste…
-
1
votes2
answers77
viewsHelp for Regular Expression construction
Regarding the string identified below, I needed to get the ABCD value by using a regular expression, I need help to build that regular expression. Team(\\\'ABCD\\\')…