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

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)
new topic     » topic index » view message » categorize

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

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 message » categorize

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

_tom said...

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

Comments are welcome!

Can you put cell borders in that table? Would help with readability.

new topic     » goto parent     » topic index » view message » categorize

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

euphoric said...

Can you put cell borders in that table? Would help with readability.

Good point, it bothers me also.

This creolecode...

|= A |= B | 
|test | TEST | 

makes this table...

A B
test TEST


I do not know how to make borders.

When making a pdf of the documentation, it is the same problem. I did learn that if I manually edit the html that goes into the htmldoc program, it is possible to make borders in the pdf version--but that is a lot of work.

new topic     » goto parent     » topic index » view message » categorize

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

euphoric said...

Can you put cell borders in that table? Would help with readability.

Ok, I've played around with the table borders and colors. Let me know if it can still be improved some more.

new topic     » goto parent     » topic index » view message » categorize

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

DerekParnell said...
euphoric said...

Can you put cell borders in that table? Would help with readability.

Ok, I've played around with the table borders and colors. Let me know if it can still be improved some more.

One thing I think we need to do is distinguish colors between visited and non-visited forum links. The star graphic is likely to work less and less (already doesn't work on Chrome).

Matt

new topic     » goto parent     » topic index » view message » categorize

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

Looking good. The blank rows could use some differentiation probably. If a user wants a blank row, let him specific somehow.

Putting a space in table cells causes this:

Header 1 Header 2
First row below 1st blank row First row below 1st blank row
First row below 2nd blank row First row below 2nd blank row

Putting no spaces causes this:

||Header 1||Header 2|| 
||| 
|First row below 1st blank row|First row below 1st blank row| 
||| 
|First row below 2nd blank row|First row below 2nd blank row| 

Could not display that table because it was crashing. Derek, if you edit or preview this message, remove the {{{}}} and you'll get the crash. :/

A   causes this:

Header 1 Header 2
&npsp; &npsp;
First row below 1st blank row First row below 1st blank row
&npsp; &npsp;
First row below 2nd blank row First row below 2nd blank row

Oops! I don't know how to make a   in creole markup. Is there a way to enter raw HTML?

new topic     » goto parent     » topic index » view message » categorize

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

euphoric said...

Putting no spaces causes this:

||Header 1||Header 2|| 
||| 
|First row below 1st blank row|First row below 1st blank row| 
||| 
|First row below 2nd blank row|First row below 2nd blank row| 

Could not display that table because it was crashing. Derek, if you edit or preview this message, remove the {{{}}} and you'll get the crash. :/

I've just submitted a fixed creole that allows you to enter empty cells without having to use a blank between the bars.

euphoric said...

A   causes this:

Header 1 Header 2
&npsp; &npsp;
First row below 1st blank row First row below 1st blank row
&npsp; &npsp;
First row below 2nd blank row First row below 2nd blank row

Oops! I don't know how to make a   in creole markup. Is there a way to enter raw HTML?

No. There is no way to enter raw HTML.

However, I've added a new markup code for creole. If you need a non-breaking space you can use a double ampersand. For example ...

   this&&doesn't&&break 

will display as "this doesn't break" with each word on the same line.

The upgrade to creole has just been submitted so it might take a little while to get to the web server.

new topic     » goto parent     » topic index » view message » categorize

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

DerekParnell said...

The upgrade to creole has just been submitted so it might take a little while to get to the web server.

I just updated it. But you have the same level of access as I and euphoric do, so there should be no reason for a delay. :P

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu