Skip to content

Tag: regex

Partial Matching of Regular Expressions

In NFA it is easy to make all previously non-final states accepting to make it match language of all substrings of a given language. In Java regex engine, is there a way to find out if a string is a starting substring of a string that matches given regex? expression regexX ~ “any start of”, regexA…

Use pattern in getAttribute in NiFi

How can I use a pattern in getAttribute of a FlowFile? I’m going to write a processor that receives flowfiles from ListenTCP and ListenUDP processors. ListenTCP has tcp.sender property and ListenUDP has udp.sender property. How can I get the sender property of a FlowFile? The current solution is: How ca…

Mapping SQL NUMERIC[10,0] to java type

I need to map NUMERIC[10,0] parameter type of a sybase stored procedure to a java type. What would be this type? Also, if you can help me define a regular expression for this NUMERIC[10,0] type I’ll be greatful. Answer Use Long as Integer is to short to map all possible values. Have a look at MAX_VALUE …

Regex for polynomial expression

I have a string that I hope is a polynomial expression, something like “2x^2-3x+1. I want to use a regex to group each term in the expression. I currently have “^(-?d?x(^d)?)+”. I’m trying to capture a term as an optional minus sign, then a number, then x, then an optional exponent, wh…

Java: Extracting a specific REGEXP pattern out of a string

How is it possible to extract only a time part of the form XX:YY out of a string? For example – from a string like: sdhgjhdgsjdf12:34knvxjkvndf, I would like to extract only 12:34. ( The surrounding chars can be spaces too of course ) Of course I can find the semicolon and get two chars before and two c…

Unique regex for first name and last name

I have a single input where users should enter name and surname. The problem is i need to use checking regEx. There’s a list of a requirements: The name should start from Capital Letter (not space) There can’t be space stacks It’s obligate to support these Name and Surname (all people are ab…

Are non-capturing groups redundant?

Are optional non-capturing groups redundant? Is the following regex: semantically equivalent to the following regex? Answer Your (?:wo)?men and (wo)?men are semantically equivalent, but technically are different, namely, the first is using a non-capturing and the other a capturing group. Thus, the question is…