string funcs

This commit is contained in:
hugo 2017-07-15 11:33:24 -07:00
parent 915a4b21f7
commit 3d3ab700d1

View File

@ -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"