search-replace table (made by S.P and D.P)
- Posted by _tom (admin) Jul 30, 2010
- 1386 views
Shawn Pringle has created a table (more comprehensive than this version) to summarize the available search-replace routines in Euphoria. Derek Parnell then made an html variant. I have merely converted Derek's table into creole format so see how it will fit into to documentation.
This table looks like it should be added as a "miniguide" in the documentation. I am willing to turn this into an article. If anyone has some ideas, just give me a few hints or rough text, and I will finsh the work.
--
Find-Replace table
description | simple member | any member | slice | regular expression slice | wildcard |
---|---|---|---|---|---|
Return first index to match | find() find_from() |
find_any() | match() match_from() |
re:find() | |
Return all indexes to match | find_all() | find_each() | match_all() | re:match_all() | |
|
|||||
Split based on match | split() | split_any() | split() | re:split() | |
|
|||||
Replace match with supplied data | replace_all() | transmute() | replace_all() | re:find_replace() | |
Replace match with supplied data to some limit | search:find_replace() | transmute() | search:match_replace() | re:replace() re:find_replace_limit() |
|
Removing match | remove_item remove_all |
transmute() | |||
|
|||||
Indicate a match | equal() | match_any() | equal() | re:is_match | wildcard:is_match() |
--
Notes:
- the wildcard syntax is much "friendlier" than "regex" syntax (but much less powerful)
- built-in routines shown with no namespace prefix
- routines from libraries are using a prefix
- include std/search.e as search
- include std/regex.e as re
- include std/wildcard.e as wildcard
--
Some questions:
- would "element" be a better term than "memember" in this table? ( as in, we think in terms of elements of a sequence)
- can I assume that the speed advantage goes as: built-in (fastest), std/library, regular expression (slowest)