0

I can't seem to figure out the regex I need. This is what I want to achieve:

{ANY CHAR} + @javax.persistence.Column(name = "{ANY 30 CHARS}") + {ANY CHAR}

Also I think where I'm struggling with: the "name = " might be "name=" or "name ="

What would the regex be to search like this in Java?

3
  • 1
    use \s* for 0-n spaces. Commented Mar 18, 2016 at 9:48
  • 3
    \\bname\\s*=\\s* Commented Mar 18, 2016 at 9:48
  • Aha, tnx. How would the full regex look like then? Tnx Commented Mar 18, 2016 at 10:01

3 Answers 3

1

Full regex should look like,

.*@javax\\.persistence\\.Column\\(name\\s*=\\s*\".{30}\"\\).*
Sign up to request clarification or add additional context in comments.

1 Comment

.{30} expects exactly 30 chars , for 1 to 30, use {1,30}
0

Have a look at: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

Here you should find all the info you need for a specific number of characters / whitespaces etc.and general regex patterns.

Comments

0

From your description:

 ".@javax\\.persistence\\.Column\\(name ?= ?\".{30}\"\\)."

Though this is probably not what you want, as it matches exactly 30 chars - seems unusual to me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.