Home > DeveloperSection > Forums > How to match text between double slashes but not url?
Ida B Wells
Ida B Wells

Total Post:30

Posted on    October-14-2013 3:43 AM

 Java Java 

 1 Reply(s)
 866  View(s)
Rate this:

I need to replace double slashes in a wiki markup with something else (double slashes stands for italic text).

How can I match italic text, without URLs?

This regexp is for a text where are no URLs: //(.*?)//

Problem appears when there is a text like:

//italic text// and this is only http://some.url/somewhere and this is //another italic text// yeah

I'm using Java.

Garry Winogrand
Garry Winogrand

Total Post:24

Posted on    October-14-2013 4:09 AM

Hey Ida

Use this Code:


It requires that // does not have : in front of it. This would catch most URL forms.

Also, I changed your (.*?) to (.+?) - it requires at least 1 character between // to be valid - your code would allow ////.

Don't want to miss updates? Please click the below button!

Follow MindStick