Technical References - [grep]

Replaces text based on a regular expression.

numero = 238
interpreted = N
texte = [grep search=regexp&replace=regexp]Any Text[/grep] This popular UNIX utility has been adapted to WebDNA. Example (normally you would put the following text into a .dna file on your server and use a web browser to link to it):
[grep search=([0-9]*-[0-9]*)&replace=<strong>\1</strong>]Hi, my phone number is 555-1234, and I'd like you to call me[/grep]
In the example above, the displayed text will be Hi, my phone number is 555-1234, and I'd like you to call me
search(Required) Regular expression that defines what text to search for in the body of the context
replace(Required) Regular expression that defines how to output the resulting text

IgnoreCase

(Optional) ignores case sensitivity while performing the grep function
There is a new 'IgnoreCase' parameter for the [grep] context. Here is an example: Search for 'usa' and replace with 'USA'
[grep search=usa&replace=USA&ignorecase=T]I was born in the usAI was born in the uSaI was born in the Usa[/grep]
Results: I was born in the USA I was born in the USA I was born in the USA The following example removes html tags
[grep search=(<[a-z]*>[^<>]*<\/[a-z]*>|<[a-z]*>)&replace=]<script> remove the code 1 that's here</script> 1but not here<br> <hr><script> remove the code 2 that's here</script> 2but not here<br> <hr><script> remove the code 3 that's here</script> 3but not here<br> <hr>[/grep]
Results: 1but not here 2but not here 3but not here [grep search=regexp&replace=regexp]Any Text[/grep]

This popular UNIX utility has been adapted to WebDNA.
Example (normally you would put the following text into a .dna file on your server and use a web browser to link to it):

[grep search=([0-9]*-[0-9]*)&replace=<strong>\1</strong>]Hi, my phone number is 555-1234, and I'd like you to call me[/grep]

In the example above, the displayed text will be

Hi, my phone number is 555-1234, and I'd like you to call me

search(Required) Regular expression that defines what text to search for in the body of the context
replace(Required) Regular expression that defines how to output the resulting text

IgnoreCase

(Optional) ignores case sensitivity while performing the grep function


There is a new 'IgnoreCase' parameter for the [grep] context. Here is an example:

Search for 'usa' and replace with 'USA'

[grep search=usa&replace=USA&ignorecase=T]
I was born in the usA
I was born in the uSa
I was born in the Usa
[/grep]

Results:

I was born in the USA
I was born in the USA
I was born in the USA

The following example removes html tags

[grep search=(<[a-z]*>[^<>]*<\/[a-z]*>|<[a-z]*>)&replace=]
<script> remove the code 1 that's here</script> 1but not here<br> <hr>
<script> remove the code 2 that's here</script> 2but not here<br> <hr>
<script> remove the code 3 that's here</script> 3but not here<br> <hr>
[/grep]


Results:

1but not here 2but not here 3but not here

DOWNLOAD WEBDNA NOW!

Top Articles:

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

Tips and Tricks

A list of user-submitted tips ...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

WebDNA Modules

A list of the currently available modules...

WebDNA Libraries

A list of available libraries for WebDNA...

[biotype]

BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...

Related Readings:

[calcfilecrc32]

calculates the CRC32 value of a given file...

[movefile]

This instructions move a file from one location to another...

[listfields]

Lists all the fields in the specified database...

[xmlnodes]

The behavior of this context is to iterate the child XML nodes of a parent node...

[table]

[table] allows you to quickly create a temporary 'in line' database that is local to the template and not part of the global database cache...

[ddesend]

Sends text to a DDE server program on the local machine...