Questions tagged as 'regex'

3
answers

Regex for hexadecimal colors

I have a little doubt: I have a regex that captures in 3 groups (2 values per group) of a certain color, but this when I have 6 values (excluding #), I would like to know how to implement to catch < strong> 1 group when the color is for example...
asked by 27.03.2014 / 18:04
2
answers

Regex to replace commas and spaces together

I have the text in the string below: string = "ele, joao gosta de maria, mas maria gosta de jose"; string = string.replace(/???/g,", "); See that some words have more or less spaces between them, and may still have commas...
asked by 01.04.2018 / 01:40
1
answer

Validate text with regex

I have the following code: final String msgRegex = "Produto [a-Z0-9À-ú, ]*"; final String msg = "Produto Soja"; if (msg.equals(msgRegex)) { System.out.println("Verdadeiro"); } else { System.out.p...
asked by 26.03.2018 / 15:10
3
answers

How do I marry this range of elements?

How do I get text between these two elements, for example: a) texto <br /> texto texto texto <br /> I would like to take what is between a) and <br /> of the end, only the end: "texto <br /> texto tex...
asked by 01.12.2017 / 21:04
2
answers

How to construct this regular expression?

I'm trying to build a regular expression and it's a bit difficult. I would like you to help me, and if possible explain how the computer works in relation to this expression I am asking. I need to get everything at the beginning of a Strin...
asked by 30.12.2016 / 22:59
3
answers

How to catch reps of a certain group with regex?

I'm trying to capture a certain structured data, and I need it to capture a certain group as long as there are possibilities. The format of the data is as follows:    foo01 @ key1 | value1 # keyN | valueN Where the first group consists...
asked by 13.09.2017 / 22:03
2
answers

Get only the first name, after space using Java

Good afternoon. I have the following String:    "Carlos Ferreira da Silva" I wanted to get only the first name and ignore rest after the "space". Using regular expressions, how could I do this?     
asked by 07.03.2017 / 21:45
2
answers

How to remove backslashes (\) and quotation marks (") from a string?

I would like to prevent the use of these characters in a string. I think the most elegant way would be by regular expression, but I do not understand anything about how to put one together. A replace would also help.     
asked by 06.08.2014 / 15:08
2
answers

Regex to select only numbers from 1 to 2,000

I'm doing a search to return the article numbers, I used: preg_match_all('/\d+/', $novalinhas, $matches); $artigo = (int)implode('',$matches[0]); It's working, however, in some articles it takes more numbers than the article, but it does...
asked by 24.04.2015 / 15:51
2
answers

Variable to validate 'Login' field?

I'm having trouble creating a variable to validate my Login field. For example, in my 'First Name' and 'Last Name' fields, I have this variable: var padrao = /[^a-zà-ú]/gi; In this way, if 'Name' or 'Last name' does not conform to that...
asked by 20.06.2018 / 03:27