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
votes2
answers76
viewsHow do you capture the time in a String?
I am making a javascript code where I will need to divide a sentence so that I look for the hours, I just want their value and so that I can separate them, to put the value separately. Ex: String:…
-
1
votes2
answers522
viewsDoubt preg_match PHP
I need to make a preg_match to check whether a string meets the following conditions: Start with a letter: a-z; Contain only letters, number and characters ,, ., - and _; Current code:…
-
1
votes0
answers92
viewsHow to validate this regex? AA-000
I’m building a regular expression to validate plane registrations. They are always in this sequential format: 2 capital letters A to Z Hyphen 3 numbers Totaling 6 characters. I did the following…
-
1
votes1
answer241
viewsRemove comments from HTML
I have a TXT taken from an HTML file. It is full of comments that I need to remove and so I thought to use the method replaceAll class String, doing the following: public static void main(String[]…
-
1
votes2
answers511
viewsBring only the first occurrence of a regex
How to search in a query only the first date? For example: 30/09/2018 and 14/10/2018 and 21/10/2018 I would like to bring only the first date. I am using so, [0-9]{2}/[0-9]{2}/[0-9]{4}, but it…
-
1
votes1
answer285
viewsHow to create a regex in Python to get a specific text?
For example, I want to take the string below: TEXT ABOVE MR. DR. DR. JUDGE OF LAW SPECIAL COURT CIVIL DISTRICT OF THE CAPITAL TEXT BELOW The word DEAR. may be replaced by EXCELLENCY and the word…
-
1
votes2
answers66
viewsShow only larger records two days before today
I have the following Query in MYSQL: SELECT id_tabela,titulo,data_gabarito,left(data_gabarito,10) AS d_gabarito FROM tabela WHERE data_gabarito RLIKE('^[0-9]{2}/[0-9]{2}/[0-9]{4}') ORDER BY…
-
1
votes2
answers1361
viewsForm validation using regex and Javascript
I’m having difficulty validating my form, I’m trying to validate with Javascript, but until now I could not validate all fields. It only validates the field that is last in the code. For example, in…
-
1
votes0
answers140
viewsGet only the first occurrence of R1: with regex
I have the following text:: R1:C1[6]|R1:C1[12]-[P1_G] I need to get only the first R1:. I tried doing a lazy regex R[\d+]?: ,but I didn’t get the result I needed and I didn’t understand why it…
regexasked 5 years, 9 months ago Jéssica Campos 21 -
1
votes1
answer178
viewsHow to indent a yaml file using regular expression?
PROD ="IND" LOCATION ="NY" LOLO ="abc" yaml_content = """ MAIN : PROD : {} LOCATION : {} EXTRA : LOLO : {} """.format(PROD, LOCATION, LOLO) yaml_content = re.sub("\n\s", "\n", yaml_content.strip())…
-
1
votes3
answers1988
viewsEmail validation function
I need help with this code 'cause I’m racking my brain and I can’t fix it. You first enter the number of emails you want to enter with input. Then you type the emails according to the number you…
-
1
votes2
answers1248
viewsExpression to treat URL with parameter
NOTIFYING The solutions below, only will not have great serventias, with them it is necessary to have previously already implemented URL friendly, and also checks of display of the contents of the…
-
1
votes2
answers215
viewsSplitting a string into an array of strings from the occurrence of a date
I need to separate a string, similar to the example below, into an array of strings starting from the event time date and event code (e.g.: 03/07/2019, 15:43 -104) and ending until the next…
-
1
votes2
answers150
viewsRegular expression validation is invalid even when you find a match
I’d like to know what’s wrong with that code. All valid values I enter in the name, email and phone are invalid, even if in the format requested by regex. import re class Contato: def…
-
1
votes2
answers255
viewsRegex take value from previous line
Text the text below and would like to pick up the value of the line above the word "OUTRAS INFORMAÇÕES", in this case the value 8.571.962,06. I did it this way, but I’m finding it very vulnerable:…
regexasked 5 years, 8 months ago user2254936 185 -
1
votes1
answer93
viewsRegex separates by type of occurrences, how to do and the simple way to achieve?
Hello, I am working with user-agent and would like a help. I want to separate a value from a string that has this pattern: Mozilla/<version> (<system-information>) <platform>…
-
1
votes0
answers60
viewsHow to capture full names and numbers with alphanumerics in Ruby from a.txt file
I tried to do something like that , but he only picks up the numbers after / in the case of enrollment and the names he only takes the first name of the person and if there is no accent , and I do…
-
1
votes1
answer239
viewsRegex to remove HTML Entity
I have an excerpt of HTML in which I extract some information. However in one of these HTML is coming the code + in the middle, which means the sign +. I tried a few ways but no removing that…
-
1
votes1
answer116
viewsRemoving comma from the pl sql column
Good afternoon, I have a table that has names. In some lines the name is separated by comma. Ex: Alberto, Luiz I want to change these lines to stay Luiz Alberto DECLARE final VARCHAR(50); inicio…
-
1
votes0
answers17
viewsRedirectmatch is triggering another rule in . htacces triggering unwanted behavior
I’m trying to make the following redirect https://www.example.com/alguns-diretorios-diferentes/0-todas-pr for https://www.example.com/alguns-diretorios-diferentes/0-todas-as-cidades-pr I added the…
-
1
votes2
answers413
viewsInputmask Regex
I need a mask that gives me this result: FB.B0.C6.E2.65.EB.D3.09.42.EB.23.C0.23.BE.D5.EF.D6.BB.A7.7C-6 Note that between the dots the characters are random, may be letters and numbers, but every 2…
-
1
votes0
answers114
viewsIgnore some fields with regex
In PHP I’m using preg_match_all to get some data from this form: <form id="login_form" action="/login/device-based/regular/login/?login_attempt=1&lwv=100" method="post" onsubmit="">…
-
1
votes0
answers36
viewsNsregularexpression replacingOccurrences with multiple templates
I’m having difficulties to replace different templates in a text, my Regex returns more than one need to replace according to the variable value strReplaced Follows code: import Foundation let texto…
-
1
votes1
answer133
viewsRegex - How to recover the first occurrence of two uppercase letters after a comma in Mysql?
I have the following text:: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sodales porta tempor. Praesent eleifend volutpat nulla, BA at aliquet libero. Vivamus est eros, convallis…
-
1
votes2
answers213
viewsFind letters in the middle of the preg_grep array
I’m really bad at doing this kind of research and I don’t have much idea how to do it, the way I did I can only locate the word if written in full if it’s in sequence (from start to finish). How can…
-
1
votes2
answers430
viewsRegex to get different snippets of a file
I need to make a regex that takes the address of the person. I can receive 2 types of text with the address. In the first case it comes alone, and get with this regex:…
-
1
votes1
answer76
viewsHow to select standard words using Regex?
I want to validate this regex: - regex.test.test.test.test - -regex.test.test.test.test - +regex.test.test.test.test If you take a trace from the beginning to the word, I want this regex to be…
-
1
votes2
answers1159
viewsHow to use the Pattern attribute with regular expression correctly?
I’d like to use one pattern in my input (has to be the text) with the following rules: Input only accepts up to 4 characters. These characters can only be numbers from 0 to 9. User CANNOT start…
-
1
votes1
answer176
viewsHow to do a regex to take from bar (/) to _, ie I just want the digits before _
/dir/user/Desktop/zip/1_0.zip /dir/user/Desktop/zip/2_0.zip I want to capture only the numbers in bold. I am doing the following and sending to a foreach but it’s not capturing right:…
-
1
votes1
answer613
viewspreg_replace_callback() to remove characters that are not digits
I use Laravel and am trying to use the function preg_replace_callback() to remove point, comma, hyphen, dash and bar from the CNPJ numbers entered in the system. I used the function…
-
1
votes2
answers257
viewsHow to recover a specific chunk of text
I have a configuration file and need to get a specific chunk of a configuration, which would be the best way to do this? In the example below I need to take the section that starts in "config system…
-
1
votes2
answers1070
viewsRegular expression for alphanumeric characters, hyphen, space or single quotes
I’m looking for a regex that accepts alpha-numeric characters, spaces, ' and -. These examples should be accepted: "Jean-da Silva", "Carlos 2", "João d'lango". Examples not accepted: "J@ão",…
-
1
votes2
answers69
viewsPreg Replace to remove awesome font from the texts
I need to ride a preg_replace PHP to remove all font-awesome of a string. for example.: Texto de teste <i class="fab fa-accusoft"></i> Teste Lorem Ipsim I’d have to change to Texto de…
-
1
votes1
answer168
viewsHow to find and change a pattern without replacing the other elements of a String with regex?
I have a template qualquer nome:{{UDA_numero qualquer}} that comes "loose" in a String. In that String, there can be "n" templates, words, numbers, etc. The goal is to catch this "any number" from…
-
1
votes1
answer79
viewsHow to locate 2 matches that are interspersed with the same regex
In the following string: 83/80/95 I need you to find 83/80 and 80/95, using the same regex. I am using the following regex: (\d{2,4})[\/](\d{2,4}) The first Match "83/80" is found, but the second is…
-
1
votes1
answer226
viewsRegex to validate a specific amount of sequence appearances " - "
I need to apply a regex pattern to a title. regex is saved to the bank and the title is only accepted if it is within the default. The pattern is as follows: text - text - text In this title there…
regexasked 5 years, 1 month ago giovanni jakubiak 13 -
1
votes2
answers127
viewsHow to give Match in word with several alternatives?
I’m trying to give match us type of input that there is, however, the word "datetime-local" is causing me trouble, because if it is "datetime" he also finds a match. For my expression to be correct…
-
1
votes2
answers312
viewsRegex catch value between two words
I need to take the amount 62.715,90 between the words TOTAL and DEDUÇÕES. In the OCR is the line break according to the text below. I’m using Regular Expressio Design software. NOME: TESTE DE SILVA…
regexasked 5 years ago user2254936 185 -
1
votes1
answer42
viewsGet value 3 lines after given word
I have the OCR below and I need to get the value 254.878,00, in the regex I did is picking the value 8.571.962,06. By the word OUTRAS INFORMAÇÕES would be ideal because the text is bold and always…
regexasked 5 years ago user2254936 185 -
1
votes1
answer768
viewsConditional formatting of Regex phone number
Context: have a input that as I type a function is called to check if the phone number is in the correct format. This function must accept numbers in the formats: (XX)XXXXX-XXXX and (XX)XXXX-XXXX,…
-
1
votes1
answer413
viewsData processing in JSON format with Regex in Javascript
I have a problem in a project with PHP backend and front in HTML, Javascript and CSS. The backend is sending the data to the front through JSON, however, in one of the excerpts of the data there are…
-
1
votes1
answer147
viewsHow to validate a regex rule for a user quote?
I’m making a feature on my site to quote users using @: @bananinha disse aquilo In case the name @bananinha will turn into a link when the person submits the comment. I can do with a lot of if but I…
-
1
votes2
answers327
viewsI’m having trouble picking a value between two strings in PHP using REGEX
$exemplo = "Olá, como vocês estão? Eu queria pegar o valor entre esses colchetes {# Olá mundo} e que esse aqui {#Teste} não interferisse, e me retornasse:"; I’d like the code to return: [ [0] =>…
-
1
votes2
answers631
viewsHow to verify the occurrence of a given string and return part of it?
I have a small solution developed on the Node.js platform, at the moment I need to check if a given string exists, if it exists it will be necessary to capture the value INTEIRO contained in this.…
-
1
votes2
answers310
viewsRegular expression to get number between two bars
I have a code that takes a certain URL, divides it and returns me a list. url = 'https://www.site.com.br/categoria-produto/category/page/67/? gclid=Cjkdksjkcm35522' last_page = url if…
-
1
votes1
answer98
viewsOptional group is not being captured
I have a huge file of records that I want to turn into a table. The file looks like this: ******************** SemprePresente1=09/2019 SemprePresente2=987456 Um monte de coisas Que não preciso…
-
1
votes1
answer911
viewsValidate password fields using Javascript / Regex
I’m setting up a page where the user can change his password and need to validate two input’s with the following rules: the password must have 1 character and 1 number. there cannot be 2 characters…
-
1
votes2
answers622
viewsHow to Split Javascript using multiple tabs and without removing them?
I have the following Javascript code: if (v.includes("'!'")) var separators = ["\\\''", '\\\&', '\\\#', '\\\|']; else var separators = ["\\\''", '\\\'', '\\\&', '\\\#', '\\\|']; var…
-
1
votes1
answer474
viewsRemove with regex everything after two points in the SQL query
GOAL I want to remove with regex in SQL query everything after two points, can anyone help me mount this query? I made several attempts, but without success. Normal query Remove with Regex Desired…
-
1
votes2
answers253
viewsCheck if a string matches multiple conditions
I would like to know how I do to check the following code: if((lines[line].substr(0,2) == "N1" && lines[line].length == 94 && lines[line].substr(3,16) == /[0-9]/ &&…