Re: search-replace table (made by S.P and D.P)

new topic     » goto parent     » topic index » view thread      » older message » newer message

The following is a draft of what could be a "miniguide" for searching and replacing in the Euphoria documentation.

Comments are welcome!


Search Reminders

  • needle in haystack
  • element != slice
  • find ---> element
  • match ---> slice

search for element

search one
needle
multi
needle
nested
haystack
regex return
value
include
module
(*1)
indicate equal equal() 0 or 1
rank compare() -1, 0, 1
locate first find() first index
find_any()   first index std/search.e
from find_from() first index -- after start location
reverse rfind() first index -- start from right end std/search.e
all find_all() sequence of index values
find_each() sequence of index values std/search.e
find_nested()
(*2)
sequence
(*3)
std/search.e
remove one remove()   shortened sequence
all remove_all() shortened sequence
replace one replace() new sequence
all replace_all()  
find_replace()  
split split() sequence of elements
split_any() sequence of elements

Note:-


"needles" 'a' "aeiou"

(*1)
regex
see splice table
(*2)
flags for nested
NESTED_ALL std/search.e
NESTED_ANY
NESTED_BACKWARD
NESTED_INDEXES
 
(*3)
utility for nested
valid_index() 0 or 1
use sequence as index
std/sequence.e
fetch() element
use sequence as index
std/sequence.e
store() new sequence
use sequence as index
std/sequence.e

Note:

for the haystack sequence "hello" the following needles are:

'o' -- element 
"o" -- slice  (a slice of length one //only sometimes// behaves like an element) 

when searching the following haystack sequences:

"hello"            -- an element is a character such as 'o'  
{ "hello", "world" } -- an element is a string such as "hello" 

While the std/regex.e module has functions that can search for any character (element) in a string; the Euphoria routines will be faster and may be easier to use.


Note:

The Euphoria "match" and regex "matches" are both about finding a slice in a sequence. But, a regex is specific to text searchs on a string.

A regex search is capable of returning two kinds of information. The regex:find() returns index values when a search succeeds. The regex:matches() returns the actual text when a search succeeds. Caution: the regex:find() is for slices, while the eu:find() is for elements.

A regex pattern may be written for a "multi-needle" search, or as a "single-needle" literal search. There is no need for special multi-needle regex functions.

search for slice

search one needle multi-needle nested haystack regex return value include module
index text
indicate match_any() 0 or 1 std/search.e
is_match() std/regex.e
has_match() std/regex.e
locate first match() first index
find() first index pair std/regex.e
matches() text std/regex.e
from match_from() first index -- after start
find() index pair std/regex.e
matches() text std/regex./e
reverse
all match_all() sequence of index values std/search.e
std/regex.e
all_matches() std/regex.e
remove one
all
replace one
match_replace()
find_replace() std/regex.e
find_replace_limit() std/regex.e
all replace_all()  
find_replace()  
split split() sequence of elements
split() std/regex.e
split_limit() std/regex.e

Notes:

A regular expression must first be "compiled" into an internal format with new() before it can be used in regex functions.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu