Julia Quick Note [04] Regular Expression

Regular expression (example of writing)

note04


regex = r"H.*w"
m = match(regex, "I love Halloween!")
if isnothing(m)
    println("no match")
else
    println(m.match)      #Get the matched string
    println(m.offset)     #Get the matched position
end

Commentary

Regular expressions use the PCRE library. Prepend r to the string to indicate that it is a regular expression.

If it doesn't match the regular expression, the match function returns nothing. Use the isnothing () function to determine nothing.

If there is a match, an object of type RegexMatch is returned. You can get information such as matching strings and positions.

◆ Get the matched string image.png ◆ Get the matched position image.png

Lottery

Julia Quick Look Note [01] How to use variables and constants Julia Quick Look Note [02] Arithmetic Expressions, Operators [Julia Quick Note [03] Complex Numbers] (https://qiita.com/ttabata/items/225c77a4d71fafc3e482) Julia Quick Look Note [04] Regular Expression [Julia quick note [05] if statement] (https://qiita.com/ttabata/items/4f0bcff1e32f60402dfb)

(* We will continue to increase the content)

Related information

: paperclip: Julia --Official page https://julialang.org/

: paperclip: Julia --Japanese official document https://julia-doc-ja.readthedocs.io/ja/latest/index.html

: paperclip: First time Julia and installation (Windows & Linux) https://qiita.com/ttlabo/items/b05bb43d06239f968035

:paperclip: Julia - Mathematics https://docs.julialang.org/en/v1/base/math/

Opinions etc.

If you have any opinions or corrections, please let us know.

Recommended Posts

Julia Quick Note [04] Regular Expression
Julia Quick Note [03] Complex Numbers
Julia Quick Note [06] Loop processing
Julia Quick Note [10] Function (2) Application
Julia Quick Note [09] Function (1) Basics
Julia Quick Note [07] try, catch, finally
Julia Quick Note [02] Arithmetic formulas, operators
Regular expression Greedy
Regular expression re
Julia Quick Note [22] Calling Python functions and Python modules
Regular expression in regex.h
AtCoder Regular Contest 106 Note
Regular expression with pymongo
Date notation regular expression
Regular expression look-ahead, after-yomi
python regular expression memo
Regular expression matching method
Regular expression in Python
Regular expression in Python
Regular expression confirmation quiz!
Julia Quick Note [01] How to use variables and constants
Julia Quick Note [08] Variable Type (Int, Float, Bool, Char, String)
Python 處 處 regular expression Notes
Regular expression manipulation with Python
Regular expression check tool summary
String replacement with Python regular expression
100 language processing knocks 2020: Chapter 3 (regular expression)
Introduction to regular expression processing system