• Post Reply Bookmark Topic Watch Topic
  • New Topic

Matching anything that is a String with Regex (Pattern class)  RSS feed

 
Aiken Calen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to match anything in an input text, that is a string, signified by being surrounded by quotation marks.

I have been scouring the internet to find this regex, and hoping somebody here might know how to set this up.

-Aiken
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's your best try at it?
 
Rajat Jindal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write your code here and this forum will help you in making it better and first you will have to try.
 
Aiken Calen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found a solution that works:

Ok my code is

What this does is separates an input file (that is code) into all identifiers, punctuation and operators and my output thus far looks like (snippet):

214: BSTNode
215: insertHelper(BSTNode
216: current,
217: BSTNode
218: newNode)
219: {
220: if(current
221: ==
222: null)
223: {

This is not ideal yet but I would like to add one more element. That would be if there is a String anywhere, anything in between quotes, such has "This is String 3" it will come out:

214: BSTNode
215: insertHelper(BSTNode
216: current,
217: BSTNode
218: newNode)
219: {
220: if(current
221: ==
222: null)
223: {
224: "This is String 3"

So I added to the above regex like so:

Before it didn't work and perhaps it was the positioning in the massive regex.
If memory serves, I tried it everywhere
Now it works.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!