"The UCHAR types define unsigned code units of the appropriate widths.
For example, PCRE2_UCHAR16 is usually defined as uint16_t."
Modulepcre2-2.3.1GHC2021
Text.Regex.Pcre2.Foreign
A complete binding to the low-level C API.
Items here are named identically to their C counterparts. Therefore, documentation will be sparse; the official PCRE2 API docs should suffice.
Contents
- Types
- Opaque types
- The general context
- The compile context
- Compile context setters
- The match context
- Match context setters
- Checking build-time options
- Compiling a pattern
- Main compile options
- Extra compile options
- Locale support
- Information about a compiled pattern
- Duplicate capture group names
- Callouts
- Callout struct getters
- pcre2_callout_block
- pcre2_callout_enumerate_block
- pcre2_substitute_callout_block
- The match data block
- Matching a pattern
- Match options
- Match errors
- UTF-16-specific errors
- DFA matching
- DFA matching options
- DFA matching errors
- Returned string and captured substrings
- Creating a new string with substitutions
- Substitution options
- Substitution errors
- Other information about a match
- Obtaining a textual error message
- Iterating over all matches
- Pattern serialization
Synopsis
- type PCRE2_UCHAR
- type PCRE2_SPTR
- type PCRE2_SIZE
- data Pcre2_general_context
- data Pcre2_compile_context
- data Pcre2_match_context
- data Pcre2_callout_block
- data Pcre2_substitute_callout_block
- data Pcre2_code
- data Pcre2_match_data
- data Pcre2_callout_enumerate_block
- value pcre2_general_context_create
- value pcre2_general_context_copy
- value pcre2_general_context_free
- value pcre2_general_context_finalizer
- value pcre2_compile_context_create
- value pcre2_compile_context_copy
- value pcre2_compile_context_free
- value pcre2_compile_context_finalizer
- value pcre2_ERROR_BADDATA
- value pcre2_set_bsr
- value pcre2_BSR_ANYCRLF
- value pcre2_BSR_UNICODE
- value pcre2_set_character_tables
- value pcre2_set_compile_extra_options
- value pcre2_set_max_pattern_length
- value pcre2_set_newline
- value pcre2_NEWLINE_CR
- value pcre2_NEWLINE_LF
- value pcre2_NEWLINE_CRLF
- value pcre2_NEWLINE_ANY
- value pcre2_NEWLINE_ANYCRLF
- value pcre2_NEWLINE_NUL
- value pcre2_set_parens_nest_limit
- value pcre2_set_compile_recursion_guard
- value pcre2_match_context_create
- value pcre2_match_context_copy
- value pcre2_match_context_free
- value pcre2_match_context_finalizer
- value pcre2_set_callout
- value pcre2_set_substitute_callout
- value pcre2_set_offset_limit
- value pcre2_UNSET
- value pcre2_set_heap_limit
- value pcre2_set_match_limit
- value pcre2_set_depth_limit
- value pcre2_config
- value pcre2_CONFIG_BSR
- value pcre2_CONFIG_COMPILED_WIDTHS
- value pcre2_CONFIG_DEPTHLIMIT
- value pcre2_CONFIG_EFFECTIVE_LINKSIZE
- value pcre2_CONFIG_HEAPLIMIT
- value pcre2_CONFIG_JIT
- value pcre2_CONFIG_JITTARGET
- value pcre2_CONFIG_LINKSIZE
- value pcre2_CONFIG_MATCHLIMIT
- value pcre2_CONFIG_NEWLINE
- value pcre2_CONFIG_NEVER_BACKSLASH_C
- value pcre2_CONFIG_PARENSLIMIT
- value pcre2_CONFIG_STACKRECURSE
- value pcre2_CONFIG_TABLES_LENGTH
- value pcre2_CONFIG_UNICODE_VERSION
- value pcre2_CONFIG_UNICODE
- value pcre2_CONFIG_VERSION
- value pcre2_compile
- value pcre2_ZERO_TERMINATED
- value pcre2_code_free
- value pcre2_code_finalizer
- value pcre2_code_copy
- value pcre2_code_copy_with_tables
- value pcre2_ANCHORED
- value pcre2_ALLOW_EMPTY_CLASS
- value pcre2_ALT_BSUX
- value pcre2_ALT_CIRCUMFLEX
- value pcre2_ALT_VERBNAMES
- value pcre2_AUTO_CALLOUT
- value pcre2_CASELESS
- value pcre2_DOLLAR_ENDONLY
- value pcre2_DOTALL
- value pcre2_DUPNAMES
- value pcre2_ENDANCHORED
- value pcre2_EXTENDED
- value pcre2_EXTENDED_MORE
- value pcre2_FIRSTLINE
- value pcre2_LITERAL
- value pcre2_MATCH_INVALID_UTF
- value pcre2_MATCH_UNSET_BACKREF
- value pcre2_MULTILINE
- value pcre2_NEVER_BACKSLASH_C
- value pcre2_NEVER_UCP
- value pcre2_NEVER_UTF
- value pcre2_NO_AUTO_CAPTURE
- value pcre2_NO_AUTO_POSSESS
- value pcre2_NO_DOTSTAR_ANCHOR
- value pcre2_NO_START_OPTIMIZE
- value pcre2_NO_UTF_CHECK
- value pcre2_UCP
- value pcre2_UNGREEDY
- value pcre2_USE_OFFSET_LIMIT
- value pcre2_UTF
- value pcre2_EXTRA_ALLOW_SURROGATE_ESCAPES
- value pcre2_EXTRA_ALT_BSUX
- value pcre2_EXTRA_BAD_ESCAPE_IS_LITERAL
- value pcre2_EXTRA_ESCAPED_CR_IS_LF
- value pcre2_EXTRA_MATCH_LINE
- value pcre2_EXTRA_MATCH_WORD
- value pcre2_maketables
- value pcre2_maketables_free
- value pcre2_pattern_info
- value pcre2_INFO_ALLOPTIONS
- value pcre2_INFO_ARGOPTIONS
- value pcre2_INFO_EXTRAOPTIONS
- value pcre2_INFO_BACKREFMAX
- value pcre2_INFO_BSR
- value pcre2_INFO_CAPTURECOUNT
- value pcre2_INFO_DEPTHLIMIT
- value pcre2_INFO_FIRSTBITMAP
- value pcre2_INFO_FIRSTCODETYPE
- value pcre2_INFO_FIRSTCODEUNIT
- value pcre2_INFO_FRAMESIZE
- value pcre2_INFO_HASBACKSLASHC
- value pcre2_INFO_HASCRORLF
- value pcre2_INFO_HEAPLIMIT
- value pcre2_INFO_JCHANGED
- value pcre2_INFO_LASTCODETYPE
- value pcre2_INFO_LASTCODEUNIT
- value pcre2_INFO_MATCHEMPTY
- value pcre2_INFO_MATCHLIMIT
- value pcre2_INFO_MAXLOOKBEHIND
- value pcre2_INFO_MINLENGTH
- value pcre2_INFO_NAMECOUNT
- value pcre2_INFO_NAMEENTRYSIZE
- value pcre2_INFO_NAMETABLE
- value pcre2_INFO_NEWLINE
- value pcre2_INFO_SIZE
- value pcre2_ERROR_UNSET
- value pcre2_substring_nametable_scan
- value pcre2_callout_enumerate
- value pcre2_callout_block_version
- value pcre2_callout_block_callout_number
- value pcre2_callout_block_capture_top
- value pcre2_callout_block_capture_last
- value pcre2_callout_block_callout_flags
- value pcre2_CALLOUT_STARTMATCH
- value pcre2_CALLOUT_BACKTRACK
- value pcre2_callout_block_offset_vector
- value pcre2_callout_block_mark
- value pcre2_callout_block_subject
- value pcre2_callout_block_subject_length
- value pcre2_callout_block_start_match
- value pcre2_callout_block_current_position
- value pcre2_callout_block_pattern_position
- value pcre2_callout_block_next_item_length
- value pcre2_callout_block_callout_string_offset
- value pcre2_callout_block_callout_string_length
- value pcre2_callout_block_callout_string
- value pcre2_callout_enumerate_block_version
- value pcre2_callout_enumerate_block_pattern_position
- value pcre2_callout_enumerate_block_next_item_length
- value pcre2_callout_enumerate_block_callout_number
- value pcre2_callout_enumerate_block_callout_string_offset
- value pcre2_callout_enumerate_block_callout_string_length
- value pcre2_callout_enumerate_block_callout_string
- value pcre2_substitute_callout_block_version
- value pcre2_substitute_callout_block_subscount
- value pcre2_substitute_callout_block_input
- value pcre2_substitute_callout_block_output
- value pcre2_substitute_callout_block_ovector
- value pcre2_substitute_callout_block_oveccount
- value pcre2_substitute_callout_block_output_offsets
- value pcre2_match_data_create
- value pcre2_match_data_create_from_pattern
- value pcre2_match_data_free
- value pcre2_match_data_finalizer
- value pcre2_match
- value pcre2_COPY_MATCHED_SUBJECT
- value pcre2_NOTBOL
- value pcre2_NOTEOL
- value pcre2_NOTEMPTY
- value pcre2_NOTEMPTY_ATSTART
- value pcre2_PARTIAL_HARD
- value pcre2_PARTIAL_SOFT
- value pcre2_ERROR_NOMATCH
- value pcre2_ERROR_PARTIAL
- value pcre2_ERROR_BADMAGIC
- value pcre2_ERROR_BADMODE
- value pcre2_ERROR_BADOFFSET
- value pcre2_ERROR_BADOPTION
- value pcre2_ERROR_BADUTFOFFSET
- value pcre2_ERROR_CALLOUT
- value pcre2_ERROR_DEPTHLIMIT
- value pcre2_ERROR_HEAPLIMIT
- value pcre2_ERROR_INTERNAL
- value pcre2_ERROR_MATCHLIMIT
- value pcre2_ERROR_NOMEMORY
- value pcre2_ERROR_NULL
- value pcre2_ERROR_UTF16_ERR1
- value pcre2_ERROR_UTF16_ERR2
- value pcre2_ERROR_UTF16_ERR3
- value pcre2_dfa_match
- value pcre2_DFA_SHORTEST
- value pcre2_DFA_RESTART
- value pcre2_ERROR_DFA_UFUNC
- value pcre2_ERROR_DFA_UITEM
- value pcre2_ERROR_DFA_UCOND
- value pcre2_ERROR_DFA_UINVALID_UTF
- value pcre2_ERROR_DFA_WSSIZE
- value pcre2_ERROR_DFA_RECURSE
- value pcre2_ERROR_DFA_BADRESTART
- value pcre2_get_ovector_count
- value pcre2_get_ovector_pointer
- value pcre2_substring_length_bynumber
- value pcre2_substring_copy_bynumber
- value pcre2_substring_get_bynumber
- value pcre2_substring_list_get
- value pcre2_substring_list_free
- value pcre2_substring_number_from_name
- value pcre2_substring_length_byname
- value pcre2_substring_copy_byname
- value pcre2_substring_get_byname
- value pcre2_substring_free
- value pcre2_ERROR_NOSUBSTRING
- value pcre2_ERROR_NOUNIQUESUBSTRING
- value pcre2_ERROR_UNAVAILABLE
- value pcre2_substitute
- value pcre2_SUBSTITUTE_REPLACEMENT_ONLY
- value pcre2_SUBSTITUTE_GLOBAL
- value pcre2_SUBSTITUTE_MATCHED
- value pcre2_SUBSTITUTE_OVERFLOW_LENGTH
- value pcre2_SUBSTITUTE_LITERAL
- value pcre2_SUBSTITUTE_UNKNOWN_UNSET
- value pcre2_SUBSTITUTE_UNSET_EMPTY
- value pcre2_SUBSTITUTE_EXTENDED
- value pcre2_ERROR_BADREPLACEMENT
- value pcre2_ERROR_BADREPESCAPE
- value pcre2_ERROR_BADSUBSTITUTION
- value pcre2_ERROR_BADSUBSPATTERN
- value pcre2_get_mark
- value pcre2_get_startchar
- value pcre2_get_error_message
- value pcre2_next_match
- value pcre2_serialize_decode
- value pcre2_serialize_encode
- value pcre2_serialize_free
- value pcre2_serialize_get_number_of_codes
- value pcre2_ERROR_BADSERIALIZEDDATA
- value pcre2_ERROR_MIXEDTABLES
- Packagepcre2-2.3.1
- Exports247
- LanguageGHC2021
- LicenceApache-2.0
- SourceForeign.hs
Types
"The SPTR types are constant pointers to the equivalent UCHAR types,
that is, they are pointers to vectors of unsigned code units."
"...string lengths and offsets into strings of code units...are always of
type PCRE2_SIZE...currently always defined as size_t."
Opaque types
These correspond to structs that are only ever passed by reference. They simply exist for type safety and cannot be constructed in Haskell.
The general context
The compile context
Compile context setters
pcre2_set_compile_extra_options :: Ptr Pcre2_compile_context-> CUIntSee "Extra compile options" below for possible bit flags.
-> IO CInt
The match context
Match context setters
pcre2_set_offset_limit :: Ptr Pcre2_match_context-> PCRE2_SIZECan be unset. See below.
-> IO CInt
Checking build-time options
Compiling a pattern
pcre2_compile :: PCRE2_SPTR-> PCRE2_SIZECan be zero-terminated. See below.
-> CUIntSee "Main compile options" below for possible bit flags.
-> Ptr CInt-> Ptr PCRE2_SIZE-> Ptr Pcre2_compile_context-> IO (Ptr Pcre2_code)
Main compile options
Extra compile options
Locale support
Information about a compiled pattern
pcre2_pattern_info Duplicate capture group names
pcre2_substring_nametable_scan :: Ptr Pcre2_code-> PCRE2_SPTRname
-> Ptr PCRE2_SPTRfirst
-> Ptr PCRE2_SPTRlast
-> IO CInt
Callouts
Callout struct getters
These functions are not part of the official API; we provide them here. C API consumers are supposed to access struct fields directly, but the FFI cannot yet do that as of GHC 8.8.4.
pcre2_callout_block
See below for possible bit flags.
pcre2_callout_enumerate_block
pcre2_substitute_callout_block
Array of 2 (PCRE2_SIZE[2])
The match data block
pcre2_match_data_create :: CUIntovecsize
-> Ptr Pcre2_general_context-> IO (Ptr Pcre2_match_data)
Matching a pattern
pcre2_match :: Ptr Pcre2_code-> PCRE2_SPTRsubject
-> PCRE2_SIZElength
-> PCRE2_SIZEstartoffset
-> CUIntSee below for possible bit flags.
-> Ptr Pcre2_match_data-> Ptr Pcre2_match_context-> IO CInt
Match options
Match errors
UTF-16-specific errors
"Missing low surrogate at end of string"
"Invalid low surrogate follows high surrogate"
"Isolated low surrogate"
DFA matching
pcre2_dfa_match :: Ptr Pcre2_code-> PCRE2_SPTRsubject
-> PCRE2_SIZElength
-> PCRE2_SIZEstartoffset
-> CUIntoptions
-> Ptr Pcre2_match_data-> Ptr Pcre2_match_context-> Ptr CIntworkspace
-> PCRE2_SIZEwscount
-> IO CInt
DFA matching options
DFA matching errors
Returned string and captured substrings
pcre2_substring_length_bynumber :: Ptr Pcre2_match_data-> CUIntnumber
-> Ptr PCRE2_SIZElength
-> IO CInt
pcre2_substring_copy_bynumber :: Ptr Pcre2_match_data-> CUIntnumber
-> Ptr PCRE2_UCHARbuffer
-> Ptr PCRE2_SIZEbufflen
-> IO CInt
pcre2_substring_get_bynumber :: Ptr Pcre2_match_data-> CUIntname
-> Ptr (Ptr PCRE2_UCHAR)bufferptr
-> Ptr PCRE2_SIZEbufflen
-> IO CInt
pcre2_substring_list_get :: Ptr Pcre2_match_data-> Ptr (Ptr (Ptr PCRE2_UCHAR))listptr
-> Ptr (Ptr PCRE2_SIZE)lengthsptr
-> IO CInt
pcre2_substring_length_byname :: Ptr Pcre2_match_data-> PCRE2_SPTRname
-> Ptr PCRE2_SIZElength
-> IO CInt
pcre2_substring_copy_byname :: Ptr Pcre2_match_data-> PCRE2_SPTRname
-> Ptr PCRE2_UCHARbuffer
-> Ptr PCRE2_SIZEbufflen
-> IO CInt
pcre2_substring_get_byname :: Ptr Pcre2_match_data-> PCRE2_SPTRname
-> Ptr (Ptr PCRE2_UCHAR)bufferptr
-> Ptr PCRE2_SIZEbufflen
-> IO CInt
Creating a new string with substitutions
pcre2_substitute :: Ptr Pcre2_code-> PCRE2_SPTRsubject
-> PCRE2_SIZElength
-> PCRE2_SIZEstartoffset
-> CUIntoptions
-> Ptr Pcre2_match_data-> Ptr Pcre2_match_context-> PCRE2_SPTRreplacement
-> PCRE2_SIZErlength
-> Ptr PCRE2_UCHARoutputbuffer
-> Ptr PCRE2_SIZEoutlengthptr
-> IO CInt
Substitution options
Substitution errors
Other information about a match
Obtaining a textual error message
Iterating over all matches
Pattern serialization
pcre2_serialize_decode :: Ptr (Ptr Pcre2_code)codes
-> CIntnumber of codes
-> Ptr CUIntbytes
-> Ptr Pcre2_general_context-> IO CInt
pcre2_serialize_encode :: Ptr (Ptr Pcre2_code)codes
-> CIntnumber of codes
-> Ptr (Ptr CUInt)serialized bytes
-> Ptr PCRE2_SIZEserialized size
-> Ptr Pcre2_general_context-> IO CInt