aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/lib/strings/str_util.h
diff options
context:
space:
mode:
authorGravatar Igor Ganichev <iga@google.com>2017-08-29 14:42:01 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-08-29 14:46:06 -0700
commite8ce634f4a42298a8a386635f873017b6e2df8e3 (patch)
treef5f8fb1f306bd67059ff715c3da1f734b4a5a410 /tensorflow/core/lib/strings/str_util.h
parentdee5007d2440d87592e7359c87bcd2d3b40f914b (diff)
Add ArgDefCase conversion to tensorflow::str_util
PiperOrigin-RevId: 166905993
Diffstat (limited to 'tensorflow/core/lib/strings/str_util.h')
-rw-r--r--tensorflow/core/lib/strings/str_util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/tensorflow/core/lib/strings/str_util.h b/tensorflow/core/lib/strings/str_util.h
index 669f0d3c52..8cea0f0718 100644
--- a/tensorflow/core/lib/strings/str_util.h
+++ b/tensorflow/core/lib/strings/str_util.h
@@ -81,6 +81,17 @@ string Lowercase(StringPiece s);
// Return upper-cased version of s.
string Uppercase(StringPiece s);
+// Converts "^2ILoveYou!" to "i_love_you_". More specifically:
+// - converts all non-alphanumeric characters to underscores
+// - replaces each occurence of a capital letter (except the very
+// first character and if there is already an '_' before it) with '_'
+// followed by this letter in lower case
+// - Skips leading non-alpha characters
+// This method is useful for producing strings matching "[a-z][a-z0-9_]*"
+// as required by OpDef.ArgDef.name. The resulting string is either empty or
+// matches this regex.
+string ArgDefCase(StringPiece s);
+
// Capitalize first character of each word in "*s". "delimiters" is a
// set of characters that can be used as word boundaries.
void TitlecaseString(string* s, StringPiece delimiters);