---
title: "How to match text between double slashes but not url?"  
description: "How to match text between double slashes but not url?"  
author: "Anonymous User"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1665/how-to-match-text-between-double-slashes-but-not-url  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How to match text between double slashes but not url?

I need to [replace](https://yourviews.mindstick.com/view/81330/cow-antibody-research-in-usa-a-step-ahead-to-replace-plasma-therapy) double slashes in a [wiki](https://www.mindstick.com/articles/239151/why-is-a-wikipedia-page-a-perfect-choice-for-content-marketing) [markup](https://www.mindstick.com/blog/59/xaml-extensible-application-markup-language) with [something else](https://www.mindstick.com/forum/1654/can-anybody-say-my-below-code-is-a-variable-function-or-something-else) (double slashes stands for italic [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions)).

How can I [match](https://www.mindstick.com/forum/159713/regex-match-attribute-in-an-html-code) italic text, without URLs?

This [regexp](https://www.mindstick.com/forum/160351/explain-the-significance-of-metacharacters-in-regexp-in-javascript) is for a text where are no URLs: //(.*?)//

[Problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) 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.

## Replies

### Reply by Anonymous User

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 ////.


---

Original Source: https://www.mindstick.com/forum/1665/how-to-match-text-between-double-slashes-but-not-url

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
