Searchable::replace_first
fn replace_first<P: Pattern>(T hay, P pat, string with) -> string Import
Source: use text::{Searchable}; src/text.hy Returns hay with its first match of pat replaced by with.
A regex pattern expands $1 / ${name} in with.
Parameters#
| Name | Type |
|---|---|
hay | T |
pat | P |
with | string |
Returns#
string
See also#
Searchable: Pattern search methods (contains,find,split,replace_all, …) on any [Show] type, which search its display form.Searchable::contains: Returnstruewhenpatmatches anywhere inhay.Searchable::starts_with: Returnstruewhen a match ofpatstarts at the beginning ofhay.Searchable::ends_with: Returnstruewhen a match ofpatends at the end ofhay.Searchable::find: Returns the byte span of the first match ofpat, orNone.Searchable::find_all: Returns the byte spans of every non-overlapping match, left to right.Searchable::split: Returns the pieces ofhaybetween the matches ofpat.Searchable::split_once: Splitshayat the first match ofpatinto the parts before and after it.