# Processing 3 Escaping Regex Characters

**URL:** <https://discourse.processing.org/t/processing-3-escaping-regex-characters/19477>\
**Category:** Coding Questions\
**Created:** [April 6, 2020, 7:25pm UTC](https://discourse.processing.org/t/processing-3-escaping-regex-characters/19477 "2020-04-06T19:25:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Conor98](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Conor98](https://discourse.processing.org/u/Conor98)\
**Post date:** [April 6, 2020, 7:25pm UTC](https://discourse.processing.org/t/processing-3-escaping-regex-characters/19477/1 "2020-04-06T19:25:19Z")

</div>

I’m currently using the Regex .matches("") command Processing 3 to make an ipv4 address format verifier. I’ve currently got it working with the seperate sets of numbers but my problem is with the ‘.’ symbol. The ‘.’ symbol is traditionally treated as a wildcard in Regex and its the same here but for some reason I can’t escape the character by using the normal method of placing a “.” back slash in front of the character. When I try this I get the error of: “Invalid escape sequence (valid ones are \b \t \n \f \r " ’ \)”. So I was just wondering if there’s any other way to get round this that I don’t know of?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 11, 2020, 1:38am UTC](https://discourse.processing.org/t/processing-3-escaping-regex-characters/19477/2 "2020-04-11T01:38:41Z")

</div>

Hello,

I am not familiar with regex but did a quick exploration of this.

Example:

```auto
void setup()
  {
  String s = "192.168.001.001";
  //String[] m = match(s, "\\.");
  String[] m = match(s, "\\.(.*?)\\.");
  
  println("Found '" + m[1] + "' inside the tag.");
  printArray(m);
  }

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/ae8dbe7a3fad471ddaec5d57740ecbcd1bc59acc.png)

References:  
[https://processing.org/reference/match\_.html](https://processing.org/reference/match_.html)  
[https://py.processing.org/reference/string.html](https://py.processing.org/reference/string.html)

Update (I had the py version above):  
[https://processing.org/reference/String.html](https://processing.org/reference/String.html)  
`:)`

---

<div class="post-metadata">

**Author:** ![Conor98](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Conor98](https://discourse.processing.org/u/Conor98)\
**Post date:** [April 11, 2020, 2:22am UTC](https://discourse.processing.org/t/processing-3-escaping-regex-characters/19477/3 "2020-04-11T02:22:00Z")

</div>

Oh thank you very much. It appears that you need to use two backslashes to escape characters. I’ve been stuck on this for a while. I’m very grateful for your help.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 11, 2020, 3:12pm UTC](https://discourse.processing.org/t/processing-3-escaping-regex-characters/19477/4 "2020-04-11T15:12:10Z")

</div>

For more on this, see the reference page for String:

> Because a String is defined between double quotation marks, to include such marks within the String itself you must use the \*_\*_ (backslash) character. (See the third example above.) This is known as an _escape sequence_ . Other escape sequences include **\t** for the tab character and **\n** for new line. Because backslash is the escape character, to include a single backslash within a String, you must use two consecutive backslashes, as in: **\** [String / Reference / Processing.org](https://processing.org/reference/String.html)
