mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 15:43:58 +00:00
[awk] Fix wrong example output (in all languages) (#4750)
This commit is contained in:
parent
30dc33fbcd
commit
62b5f91d72
@ -209,7 +209,7 @@ function string_functions( localvar, arr) {
|
|||||||
# Both return number of matches replaced
|
# Both return number of matches replaced
|
||||||
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"
|
||||||
|
|
||||||
# Search for a string that matches a regular expression
|
# Search for a string that matches a regular expression
|
||||||
# index() does the same thing, but doesn't allow a regular expression
|
# index() does the same thing, but doesn't allow a regular expression
|
||||||
|
@ -196,7 +196,7 @@ function string_functions( localvar, arr) {
|
|||||||
# Ambas regresan el número de matches remplazados.
|
# 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"
|
||||||
|
|
||||||
# Buscar una cadena que haga match con una expresión regular
|
# Buscar una cadena que haga match con una expresión regular
|
||||||
# index() hace lo mismo, pero no permite expresiones regulares
|
# index() hace lo mismo, pero no permite expresiones regulares
|
||||||
|
@ -217,7 +217,7 @@ function string_functions( localvar, arr) {
|
|||||||
# Les deux renvoient le nombre de correspondances remplacées
|
# Les deux renvoient le nombre de correspondances remplacées
|
||||||
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"
|
||||||
|
|
||||||
# Rechercher une chaîne de caractères qui correspond à une expression
|
# Rechercher une chaîne de caractères qui correspond à une expression
|
||||||
# régulière index() fait la même chose, mais n'autorise pas les expressions
|
# régulière index() fait la même chose, mais n'autorise pas les expressions
|
||||||
|
@ -202,7 +202,7 @@ function string_functions( localvar, arr) {
|
|||||||
# Ambas retornam o número de instâncias substituídas
|
# Ambas retornam o número de instâncias substituídas
|
||||||
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"
|
||||||
|
|
||||||
# Localiza um texto que casa com uma expressão regular
|
# Localiza um texto que casa com uma expressão regular
|
||||||
# index() faz a mesma coisa, mas não permite uma expressão regular
|
# index() faz a mesma coisa, mas não permite uma expressão regular
|
||||||
|
@ -179,7 +179,7 @@ function string_functions( localvar, arr) {
|
|||||||
# 都是返回替换的个数
|
# 都是返回替换的个数
|
||||||
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"
|
||||||
|
|
||||||
# 搜索匹配正则的字符串
|
# 搜索匹配正则的字符串
|
||||||
# index() 也是搜索, 不支持正则
|
# index() 也是搜索, 不支持正则
|
||||||
|
Loading…
Reference in New Issue
Block a user