mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 10:01:38 +00:00
string funcs
This commit is contained in:
parent
915a4b21f7
commit
3d3ab700d1
@ -188,11 +188,11 @@ function arithmetic_functions(a, b, c, localvar) {
|
|||||||
|
|
||||||
function string_functions( localvar, arr) {
|
function string_functions( localvar, arr) {
|
||||||
|
|
||||||
# AWK, being a string-processing language, has several string-related
|
# AWK tiene algunas funciones para procesamiento de strings,
|
||||||
# functions, many of which rely heavily on regular expressions.
|
# y muchas dependen fuertemente en expresiones regulares.
|
||||||
|
|
||||||
# Search and replace, first instance (sub) or all instances (gsub)
|
# Buscar y remplazar, primer instancia (sub) o todas las instancias (gsub)
|
||||||
# Both return number of matches replaced
|
# Ambas regresan el número de matches remplazados.
|
||||||
localvar = "fooooobar"
|
localvar = "fooooobar"
|
||||||
sub("fo+", "Meet me at the ", localvar) # localvar => "Meet me at the bar"
|
sub("fo+", "Meet me at the ", localvar) # localvar => "Meet me at the bar"
|
||||||
gsub("e+", ".", localvar) # localvar => "m..t m. at th. bar"
|
gsub("e+", ".", localvar) # localvar => "m..t m. at th. bar"
|
||||||
|
Loading…
Reference in New Issue
Block a user