VEX —— Functions|String

该博客详细介绍了Houdini中众多字符串处理函数,包括返回字符串长度、连接字符串、检测开头结尾、判断字符类型、字符串与数字转换、大小写转换、正则匹配、路径处理、编码解码等功能,还说明了各函数的作用及部分使用规则。

目录

strlen —— 返回字符串长度

concat —— 连接字符串

join —— 以指定间隔连接字符串数组内字符串

startswith —— 检测字符串是否以指定的字符串开始

endswith —— 检测字符串是否以指定的字符串结尾

isalpha —— 判断字符串是否全是字母

isdigit —— 判断字符串是否全是数字

itoa —— 将整数转化为字符串

toupper —— 转化为大写

tolower —— 转化为小写

strip —— 移除字符串前导和尾随的指定字符

lstrip —— 移除字符串前导的指定字符

rstrip —— 移除字符串尾随的指定字符

opdigits —— 返回字符串末尾最后的数字

pluralize —— 将英文名词转化为复数

titlecase —— 返回标题格式


find —— 在字符串或数组中查找元素

match —— 判断字符串是否匹配样本

replace —— 用新字符串替换匹配老的字符串

replace_match —— 用新字符串样本替换匹配老的字符串样本

split —— 拆分字符串

splitpath —— 将文件路径拆分为目录和文件名

re_find —— 正则表达式匹配字符串

re_findall —— 正则表达式匹配字符串所有实例

re_match —— 匹配整个字符串

re_replace —— 替代匹配的字符串

re_split —— 拆分匹配的字符串

abspath —— 返回文件的完全路径

relpath —— 返回文件的相对当前houdini工作路径

relativepath —— 计算从src到dest的相对路径


chr —— 将Unicode转化为UTF8字符串

ord —— 将UTF8字符串转化为Unicode

encode —— 将字符串编码为有效的变量名

decode —— 对编码的变量名进行解码

encodeattrib —— 将字符串编码为有效的几何体属性名

decodeattrib —— 对编码的几何体属性名进行解码

encodeparm —— 将字符串编码为有效的几何体参数名

decodeparm —— 对编码的节点参数名进行解码

encodeutf8 —— 编码UTF8字符串

decodeutf8 —— 解码UTF8字符串

makevalidvarname —— 强制将字符串转化为符合变量名规则

sprintf —— 格式化输出字符串


strlen —— 返回字符串长度

int strlen(string string)

concat —— 连接字符串

string concat(string s1, string s2, ...)
string path[] = {'C:', 'Users', 'Administrator', 'Desktop'};

s@ret;
foreach(string s; path)
    if (len(@ret))
        @ret = concat(@ret, '/', s);
    else
        @ret = concat(@ret, s);

join —— 以指定间隔连接字符串数组内字符串

string join(string s[], string spacer)
string path[] = {'C:', 'Users', 'Administrator', 'Desktop'};
s@ret = join(path, '/');

startswith —— 检测字符串是否以指定的字符串开始

int startswith(string str, string startswith)

endswith —— 检测字符串是否以指定的字符串结尾

int endswith(string haystack, string needle)

isalpha —— 判断字符串是否全是字母

int isalpha(string str)

isdigit —— 判断字符串是否全是数字

int isdigit(string str)

itoa —— 将整数转化为字符串

string itoa(int number)
  • atof,字符串转化为浮点;
  • atoi,字符串转化为整数;

toupper —— 转化为大写

string toupper(string str)

tolower —— 转化为小写

string tolower(string str)

strip —— 移除字符串前导和尾随的指定字符

string strip(string value)
string strip(string value, string whitespace)
s@path = "C:/Users/Administrator/Desktop/";
s@ret = strip(@path, '/');  

lstrip —— 移除字符串前导的指定字符

string lstrip(string value)
string lstrip(string value, string whitespace)

rstrip —— 移除字符串尾随的指定字符

string rstrip(string value)
string rstrip(string value, string whitespace)

opdigits —— 返回字符串末尾最后的数字

int opdigits(string str)
int opdigits()
opdigits("/obj/geo34/box21") - returns 21
opdigits("/obj/geo34/box") - returns 34
opdigits("/obj/geo34/box2.1") - returns 1 (“.” is not a digit)

pluralize —— 将英文名词转化为复数

string pluralize(string noun)
string boxes = pluralize("box"); //boxes
string women = pluralize("woman"); //women
string geometries = pluralize("geometry"); //geometries
string phrase = pluralize("Pluralize the last word"); //Pluralize the last words

titlecase —— 返回标题格式

string titlecase(string str)
  • 始终大写第一个和最后一个单词;
  • 副标题大写;
  • 除冠词、介词和连词以外的所有单词大写;
  • 大写的连字符单词的第二部分也应大写;
  • 已包含大写字母的单词不修改;

find —— 在字符串或数组中查找元素

int find(string haystack, string needle)
int find(string haystack, string needle, int start)
int find(stri
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值