Questions tagged as 'regex'

1
answer

Format CPF or CNPJ field using Regex [duplicate]

I would like a regular expression (REGEX) to format the CPF or CNPJ field This is the code I've come so far: String cpf ="09551130401"; cpf = cpf.replaceAll("(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})", "$1.$2.$3-$4"); System.out.pri...
asked by 07.06.2016 / 13:58
3
answers

Using regular expressions with square brackets

Greetings, I have to remove any occurrence of text between brackets. For example: Eg: [Text in brackets] Text outside brackets. The output would be: "Text outside brackets"; I tried to use the following Regex: $string = "[Texto entre col...
asked by 15.08.2018 / 14:54
2
answers

Regexp extract value

I have the following strings:    "The.Office.US.S {SE} AND {EP} .The.Dundies.720p.srt"       "The Office [{SE}. {EP}] The Fight.srt" This string is a template of the name of a file, the files will be in the following form    "The.Offi...
asked by 12.06.2017 / 01:29
2
answers

Forcing backreference on regex

These days ago I asked here about a regex that validates dates and how to force the separators regex validated the following format: dd / mm / yyyy So based on it I was trying to force the separators using backreference in a regex that valida...
asked by 22.02.2018 / 22:04
3
answers

Identify repeated numeric characters in sequence

With expression [\d]{9} I can identify numeric characters if they are repeated nine times in sequence, however I only want identify if they are the same characters, for example: 111111111 // false 222222222 // false 333333333 // false...
asked by 05.10.2016 / 15:18
2
answers

Apply filters in a JTable

I have a table and in a Jpanel on it I created a textFields and combobox with the intention of using them as a filter. The method: tableRowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + busca)); Does he expect a string as a filter? If t...
asked by 21.11.2016 / 23:18
4
answers

How to create a regex to filter and delete files with a certain length in the name

I'm trying to figure out a way to delete files that windows duplicates when making multiple copies. I was able to do something by creating the code below: import java.util.*; import java.io.*; public class FileCreator{ public static voi...
asked by 25.11.2016 / 22:57
3
answers

Get content that is enclosed in parentheses using regex

I've been studying regex a lot, but I got caught trying to "clean" a text, leaving only the first occurrence, and the data in parentheses, the string is like this : $string = "Mais de - valor: R$3.21 - Tipo: (+05)"; As all text before...
asked by 20.05.2015 / 08:51
2
answers

Ignore punctuation in a sequence of numbers using Regex with Java

I have the following input: Fatura Cliente: 1.7852964.34 CPF/CNPJ: 09022317000222 I need to get only the "Customer Invoice" numbers, ignoring scores, returning only 1785296434 , for this I am using the following regex: Fatura Cli...
asked by 19.04.2018 / 15:19
2
answers

How to select with regex?

I'm trying to format text of the following type 123,345,234 //tem que ficar 123345,234 abc,def,adf //tem que ficar abcdef,adf 123,345,678,abc,qualquer,coisa //tem que ficar 123345678abcqualquer,coisa I need to remove all commas, exce...
asked by 22.01.2015 / 20:10