# \#regex

**URL:** https://discourse.julialang.org/tag/regex/127.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Documenter.jl doctest does not apply filter as expected](https://discourse.julialang.org/t/documenter-jl-doctest-does-not-apply-filter-as-expected/136706)

<div class="topic-metadata">

**Author:** [@phx](https://discourse.julialang.org/u/phx)\
**Replies:** 4\
**Last updated:** [April 16, 2026, 9:57am UTC](https://discourse.julialang.org/t/documenter-jl-doctest-does-not-apply-filter-as-expected/136706 "2026-04-16T09:57:45Z")

</div>

Hi all, I am writing the documentation for a package of mine, and in a doctest I have this output: 11-element Vector{ComplexF64}: 0.0 + 0.0im -1.617576049847552e-6 + 6.617439891157473e-23im -…

---

## [Python's replace faster than Julia's replace?](https://discourse.julialang.org/t/pythons-replace-faster-than-julias-replace/63180)

<div class="topic-metadata">

**Author:** [@alasaadstat](https://discourse.julialang.org/u/alasaadstat)\
**Replies:** 22\
**Last updated:** [October 7, 2025, 10:50pm UTC](https://discourse.julialang.org/t/pythons-replace-faster-than-julias-replace/63180 "2025-10-07T22:50:46Z")

</div>

Hi, I am currently working on regex stuffs, and I noticed that Python’s replace seems to be faster than Julia’s replace. function test(iter=100\_000) for \_ in 1:iter replace("The quick foxes run quickly.", r"…

---

## [Regex replace by group index](https://discourse.julialang.org/t/regex-replace-by-group-index/131342)

<div class="topic-metadata">

**Author:** [@paiv](https://discourse.julialang.org/u/paiv)\
**Replies:** 5\
**Last updated:** [August 5, 2025, 8:11am UTC](https://discourse.julialang.org/t/regex-replace-by-group-index/131342 "2025-08-05T08:11:59Z")

</div>

When doing string replace with regex, I want to know which capture group matched, so I can perform replacement specific to that group. For example, if matched at word boundary, the letter should be replaced with X, and …

---

## [How to replace backslash](https://discourse.julialang.org/t/how-to-replace-backslash/129816)

<div class="topic-metadata">

**Author:** [@gvanuxem](https://discourse.julialang.org/u/gvanuxem)\
**Replies:** 2\
**Last updated:** [June 12, 2025, 10:01am UTC](https://discourse.julialang.org/t/how-to-replace-backslash/129816 "2025-06-12T10:01:51Z")

</div>

Hello, For example, this one does not work: julia\> replace("foo \\spadbar{jjjd}","\\\\spad"=\>"") ERROR: ParseError: # Error @ REPL\[6\]:1:21 ulia\> replace("foo \\spadbar{jjjd}","\\\\spad"=\>"") # └┘ ── inval…

---

## [Match.jl: Getting hold of regex captures? (\`\\1\` doesn't seem to work.)](https://discourse.julialang.org/t/match-jl-getting-hold-of-regex-captures-1-doesnt-seem-to-work/126455)

<div class="topic-metadata">

**Author:** [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Replies:** 4\
**Last updated:** [March 12, 2025, 3:26am UTC](https://discourse.julialang.org/t/match-jl-getting-hold-of-regex-captures-1-doesnt-seem-to-work/126455 "2025-03-12T03:26:19Z")

</div>

In general, is it possible to get hold of regex captures outside the RegexMatch object? In particular, can we get them in a pattern match of Match.jl This is what I have found so far: using Match function matchreg(s) …

---

## [Filter dataframe with regular expression](https://discourse.julialang.org/t/filter-dataframe-with-regular-expression/76888)

<div class="topic-metadata">

**Author:** [@Mastomaki](https://discourse.julialang.org/u/Mastomaki)\
**Replies:** 8\
**Last updated:** [February 20, 2025, 2:44am UTC](https://discourse.julialang.org/t/filter-dataframe-with-regular-expression/76888 "2025-02-20T02:44:05Z")

</div>

Hello, I am trying to filter a dataframe based on values in certain column. This works fine when I use subset() with ByRow(in(\[“mytext”\])). But I get problems with regular expressions: df = subset(df, :mycol =\> x -\> By…

---

## [Using Regex() function, how do I match the end of the string?](https://discourse.julialang.org/t/using-regex-function-how-do-i-match-the-end-of-the-string/123659)

<div class="topic-metadata">

**Author:** [@francisbarton](https://discourse.julialang.org/u/francisbarton)\
**Replies:** 4\
**Last updated:** [December 10, 2024, 2:05pm UTC](https://discourse.julialang.org/t/using-regex-function-how-do-i-match-the-end-of-the-string/123659 "2024-12-10T14:05:22Z")

</div>

I am using the Regex() function to create a regular expression pattern, instead of just using r"", because I need to interpolate a variable. If I write Regex("$(f)$") - interpolating the variable f and wanting to match …

---

## [ERROR: LoadError: PCRE JIT error: no more memory](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859)

<div class="topic-metadata">

**Author:** [@TimG](https://discourse.julialang.org/u/TimG)\
**Replies:** 4\
**Last updated:** [May 8, 2024, 6:58pm UTC](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859 "2024-05-08T18:58:08Z")

</div>

I’m encountering this error and as far as I can tell it is related to my use of a regular expression. I’m using proprietary commercial data, so can’t easily share. However, I’m trying to read a set of files from a very …

---

## [Replacing brackets in a string](https://discourse.julialang.org/t/replacing-brackets-in-a-string/85478)

<div class="topic-metadata">

**Author:** [@james3](https://discourse.julialang.org/u/james3)\
**Replies:** 7\
**Last updated:** [April 27, 2024, 8:53pm UTC](https://discourse.julialang.org/t/replacing-brackets-in-a-string/85478 "2024-04-27T20:53:37Z")

</div>

I have a string such as str = "MyFunction\[x\] = ...", where x is a value. How do I replace the square brackets with parentheses such that str contains "MyFunction(x) = ..."? There can be may different values x, and in my …

---

## [Case-insensitive prefix/suffix stripping](https://discourse.julialang.org/t/case-insensitive-prefix-suffix-stripping/109871)

<div class="topic-metadata">

**Author:** [@Palli](https://discourse.julialang.org/u/Palli)\
**Replies:** 13\
**Last updated:** [February 8, 2024, 10:30pm UTC](https://discourse.julialang.org/t/case-insensitive-prefix-suffix-stripping/109871 "2024-02-08T22:30:19Z")

</div>

Sure, but where’s the fun in that? What’s not fun, is it’s kind of broken… I would want chopsuffix and chopprefix to work, well according to my definition, be able to to do e.g.: chopprefix(s, "http://", "https://")…

---

## [How to do readuntil(io, ::Regex)?](https://discourse.julialang.org/t/how-to-do-readuntil-io-regex/109855)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 0\
**Last updated:** [February 7, 2024, 7:31am UTC](https://discourse.julialang.org/t/how-to-do-readuntil-io-regex/109855 "2024-02-07T07:31:18Z")

</div>

I have a TCP connection over which I can send a command and then the remote end responds with some output followed by either OK or ERROR. For example: \>\> GETSTATE \<\< 0002 # Some status code \<\< OK To make it easier to…

---

## [Replace lines of file A using advanced regex and write to file B](https://discourse.julialang.org/t/replace-lines-of-file-a-using-advanced-regex-and-write-to-file-b/94362)

<div class="topic-metadata">

**Author:** [@Johannes\_Schweichhar](https://discourse.julialang.org/u/Johannes_Schweichhar)\
**Replies:** 16\
**Last updated:** [January 10, 2024, 10:23pm UTC](https://discourse.julialang.org/t/replace-lines-of-file-a-using-advanced-regex-and-write-to-file-b/94362 "2024-01-10T22:23:52Z")

</div>

Hi, I 've tried for quite some time now to replace a regex pattern in a large file and to write the result to second file. The replace expression using a dummy string works as expected. With the files I always end up wi…

---

## [Learning Regular Expressions in Julia](https://discourse.julialang.org/t/learning-regular-expressions-in-julia/101742)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 13\
**Last updated:** [September 10, 2023, 1:27pm UTC](https://discourse.julialang.org/t/learning-regular-expressions-in-julia/101742 "2023-09-10T13:27:52Z")

</div>

I found it difficult to learn Regular Expressions in Julia. I couldn’t understand what those different symbols in r"^\\s\*(?:#|$)" stands for ? Regular Expressions documentation is not detailed enough for many peop…

---

## [RegexMatch to NamedTuple?](https://discourse.julialang.org/t/regexmatch-to-namedtuple/22551)

<div class="topic-metadata">

**Author:** [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Replies:** 3\
**Last updated:** [August 20, 2023, 5:42pm UTC](https://discourse.julialang.org/t/regexmatch-to-namedtuple/22551 "2023-08-20T17:42:28Z")

</div>

When parsing a string with regex like m = match(r"^(?\<str\_a\>\\S+) (?\<str\_b\>\\S+)$", "abc def") it is possible to get group values like m\[:str\_a\] and so on. But how do I convert the match to namedtuple, (str\_a = "abc", str\_…

---

## [Multiway string substitution](https://discourse.julialang.org/t/multiway-string-substitution/102345)

<div class="topic-metadata">

**Author:** [@Denis\_Ivanov](https://discourse.julialang.org/u/Denis_Ivanov)\
**Replies:** 17\
**Last updated:** [August 6, 2023, 8:15pm UTC](https://discourse.julialang.org/t/multiway-string-substitution/102345 "2023-08-06T20:15:07Z")

</div>

I have set an ambitious goal of modeling some Wolfram Physics Project features into Julia. Because actually, Julia works faster and more efficiently, while the subject is very interesting. A bit later I will be happy to…

---

## [What is regex for the end of string in Julia?](https://discourse.julialang.org/t/what-is-regex-for-the-end-of-string-in-julia/102228)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 7\
**Last updated:** [July 29, 2023, 4:29pm UTC](https://discourse.julialang.org/t/what-is-regex-for-the-end-of-string-in-julia/102228 "2023-07-29T16:29:33Z")

</div>

What is regular expression for the final end of string in Julia?

---

## [What is regex for blank line in Julia?](https://discourse.julialang.org/t/what-is-regex-for-blank-line-in-julia/102230)

<div class="topic-metadata">

**Author:** [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Replies:** 3\
**Last updated:** [July 29, 2023, 2:15pm UTC](https://discourse.julialang.org/t/what-is-regex-for-blank-line-in-julia/102230 "2023-07-29T14:15:58Z")

</div>

What is regular expression for Blank Line in Julia?

---

## [Regex capture next line in text file](https://discourse.julialang.org/t/regex-capture-next-line-in-text-file/101361)

<div class="topic-metadata">

**Author:** [@Nick\_Mulholland](https://discourse.julialang.org/u/Nick_Mulholland)\
**Replies:** 7\
**Last updated:** [July 9, 2023, 4:45pm UTC](https://discourse.julialang.org/t/regex-capture-next-line-in-text-file/101361 "2023-07-09T16:45:00Z")

</div>

I’m fairly next to Julia and was wondering if anyone had some advice. I’m loving the regex feature which is working great on a line by line query for example open(filename) do file for (index, ln) in enumerate(e…

---

## [Non greedy regex match](https://discourse.julialang.org/t/non-greedy-regex-match/101268)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 4\
**Last updated:** [July 6, 2023, 5:46pm UTC](https://discourse.julialang.org/t/non-greedy-regex-match/101268 "2023-07-06T17:46:18Z")

</div>

How can I match non-greedily a regex in julia ? A general stackoverflow post mentions .\*? but it doesn’t work. Julia docs point to pcre2 site that mentions (?U) default ungreedy (lazy) but I am not sure how to use it…

---

## [Doesn't capturing groups within non capturing groups work in regex?](https://discourse.julialang.org/t/doesnt-capturing-groups-within-non-capturing-groups-work-in-regex/98029)

<div class="topic-metadata">

**Author:** [@Euhan](https://discourse.julialang.org/u/Euhan)\
**Replies:** 5\
**Last updated:** [May 13, 2023, 2:53pm UTC](https://discourse.julialang.org/t/doesnt-capturing-groups-within-non-capturing-groups-work-in-regex/98029 "2023-05-13T14:53:26Z")

</div>

I’m looking to capture a pattern like "=2.4.7.9\_" and be able to extract the numbers. I try to match it with r"=(\\d+)(:\\.(\\d+))\*\_" but that doesn’t seem to work. I expect each number to end up in a capture group but ins…

---

## [Q | Using Regex and eachmatch() to extract substrings](https://discourse.julialang.org/t/q-using-regex-and-eachmatch-to-extract-substrings/97128)

<div class="topic-metadata">

**Author:** [@Audrius-St](https://discourse.julialang.org/u/Audrius-St)\
**Replies:** 1\
**Last updated:** [April 5, 2023, 8:06pm UTC](https://discourse.julialang.org/t/q-using-regex-and-eachmatch-to-extract-substrings/97128 "2023-04-05T20:06:45Z")

</div>

Hello, I’m using a package \[Form 4.3.0\] for symbolic code optimization that outputs results in C and have written a script to convert the code to Julia. It’s worked to-date, however, I’ve run into a new problem in rece…

---

## [Verify if a daily file has been created](https://discourse.julialang.org/t/verify-if-a-daily-file-has-been-created/95912)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 6\
**Last updated:** [March 12, 2023, 11:27pm UTC](https://discourse.julialang.org/t/verify-if-a-daily-file-has-been-created/95912 "2023-03-12T23:27:47Z")

</div>

Suppose you have a series of data files that are added daily and named in the following format. folder/name-01-01-23.csv folder/name -01-02-23.csv . . . folder/name-03-10-23.csv What is the best way to verify if the …

---

## [How to improve a Generator to be more memory efficient when it is collected?](https://discourse.julialang.org/t/how-to-improve-a-generator-to-be-more-memory-efficient-when-it-is-collected/92932)

<div class="topic-metadata">

**Author:** [@camilogarciabotero](https://discourse.julialang.org/u/camilogarciabotero)\
**Replies:** 21\
**Last updated:** [January 23, 2023, 6:26pm UTC](https://discourse.julialang.org/t/how-to-improve-a-generator-to-be-more-memory-efficient-when-it-is-collected/92932 "2023-01-23T18:26:18Z")

</div>

Hi all, I wrote a function that searches through a sequence (a BioSequences.LongDNA but could also be a String) for start codons (predefined as constants subsequence searches) and generates ranges of indices correspondi…

---

## [Questions about string](https://discourse.julialang.org/t/questions-about-string/88604)

<div class="topic-metadata">

**Author:** [@zhangchunyong](https://discourse.julialang.org/u/zhangchunyong)\
**Replies:** 21\
**Last updated:** [January 16, 2023, 8:23pm UTC](https://discourse.julialang.org/t/questions-about-string/88604 "2023-01-16T20:23:06Z")

</div>

I want the number before the string c= “9S8M13S” 's S and then return 9 and 13.And I tried following. julia\> c="9S8M13S" "9S8M13S" julia\> fs=findall(r"\\d\*S",c) 2-element Vector{UnitRange{Int64}}: 1:2 5:7 julia\> first…

---

## [Feature request: How about pattern matching of \`Base.Filesystem.readdir\`?](https://discourse.julialang.org/t/feature-request-how-about-pattern-matching-of-base-filesystem-readdir/91887)

<div class="topic-metadata">

**Author:** [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)\
**Replies:** 7\
**Last updated:** [December 20, 2022, 2:55pm UTC](https://discourse.julialang.org/t/feature-request-how-about-pattern-matching-of-base-filesystem-readdir/91887 "2022-12-20T14:55:44Z")

</div>

It’s Base.Filesystem.readdir in julia: https://docs.julialang.org/en/v1/base/file/#Base.Filesystem.readdir It’s readdir in R, it has exclude argument as regular expression: readdir(dir::AbstractString=pwd(); join…

---

## [Convert string in text file into int](https://discourse.julialang.org/t/convert-string-in-text-file-into-int/89663)

<div class="topic-metadata">

**Author:** [@ahmad88](https://discourse.julialang.org/u/ahmad88)\
**Replies:** 3\
**Last updated:** [November 2, 2022, 7:14pm UTC](https://discourse.julialang.org/t/convert-string-in-text-file-into-int/89663 "2022-11-02T19:14:49Z")

</div>

I have the following textfile: initial=0 n=39 E=\[( 0 , 8 ), ( 0 , 13 ), ( 0 , 20 ), ( 0 , 22 ), ( 0 , 26 ), ( 0 , 36 ), ( 0 , 5 ), ( 0 , 10 ), ( 0 , 17 ), ( 0 , 27 ), ( 1 , 18 ), ( 2 , 5 ), ( 2 , 8 ), ( 3 …

---

## [Extracting a float from a string](https://discourse.julialang.org/t/extracting-a-float-from-a-string/43126)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 31\
**Last updated:** [October 24, 2022, 1:10pm UTC](https://discourse.julialang.org/t/extracting-a-float-from-a-string/43126 "2022-10-24T13:10:53Z")

</div>

I would like to extract a float from a string of the form strg = file\_t=0.234. In Python, I would use a package called scanf with similar functionality to what is offered in C++. I might also use regular expressions, bu…

---

## [How to remove RegexMatch() in output](https://discourse.julialang.org/t/how-to-remove-regexmatch-in-output/89158)

<div class="topic-metadata">

**Author:** [@Chintu\_sharma](https://discourse.julialang.org/u/Chintu_sharma)\
**Replies:** 1\
**Last updated:** [October 23, 2022, 6:11pm UTC](https://discourse.julialang.org/t/how-to-remove-regexmatch-in-output/89158 "2022-10-23T18:11:19Z")

</div>

filefull="main.cpp" extension\_pattern=r"\[^.\]+$" println(match(extension\_pattern,filefull)) # answer is RegexMatch("cpp") #but i need only output word "cpp"

---

## [Strange regex error (bug?)](https://discourse.julialang.org/t/strange-regex-error-bug/84759)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 3\
**Last updated:** [July 25, 2022, 6:00pm UTC](https://discourse.julialang.org/t/strange-regex-error-bug/84759 "2022-07-25T18:00:03Z")

</div>

julia\> r"^\\s\*text" r"^\\s\*text" julia\> Regex("^\\s\*text") ERROR: syntax: invalid escape sequence Julia 1.7.3 on Win10 And BTW what does the following error message mean? julia\> r"^\[:space:\]\*text" ERROR: LoadError: PCRE…

---

## [Does Julia use original PCRE or PCRE2?](https://discourse.julialang.org/t/does-julia-use-original-pcre-or-pcre2/84203)

<div class="topic-metadata">

**Author:** [@ProvocaTeach](https://discourse.julialang.org/u/ProvocaTeach)\
**Replies:** 1\
**Last updated:** [July 14, 2022, 2:36am UTC](https://discourse.julialang.org/t/does-julia-use-original-pcre-or-pcre2/84203 "2022-07-14T02:36:09Z")

</div>

Does Julia 1.7.3 use the original Perl-compatible regular expressions (PCRE) or the second version (PCRE2)? The Julia docs on regexes say Julia uses PCRE, but they link to the PCRE2 spec while making no mention of the v…

[Next page](https://discourse.julialang.org/tag/regex/127.md?match_all_tags=true&page=1&tags%5B%5D=regex)
