mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-17 20:11:57 +02:00
string funcs
This commit is contained in:
@@ -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"
|
||||||
|
Reference in New Issue
Block a user