当前位置: 首页 > news >正文

湖南涟钢建设有限公司网站企业文化

湖南涟钢建设有限公司网站,企业文化,轻云服务器 安装wordpress,西部建设网站字符串表达式运算符主要用于实现字符串操作,主要包括了大小写转换、字符串截取、拼接、替换等 一、准备工作 初始化字符串数据 db.strings.insertMany([{ "_id": "1", "comment": " Abc" },{ "_id": "2&…

字符串表达式运算符主要用于实现字符串操作,主要包括了大小写转换、字符串截取、拼接、替换等

一、准备工作

初始化字符串数据

db.strings.insertMany([{ "_id": "1", "comment": " Abc" },{ "_id": "2", "comment": "Hello World" },{ "_id": "3", "comment": " Hello World " }
])

二、去字符串($ltrim,$rtrim,$trim)

语法:

        去除开始位置的字符串:{ $ltrim: { input: <string>,  chars: <string> } }

        去除结束位置的字符串:{ $rtrim: { input: <string>,  chars: <string> } }

        去除开始和结束位置的字符串:{ $trim: { input: <string>,  chars: <string> } }

其中,

        input:代表的是需要去除字符的字符串

        chars:可选,代表的是需要去除的字符串;如果未定义,则去除空格

例子:去除开始位置的Hello

db.strings.aggregate([{$project: {"comment": {$ltrim: {input: "$comment",chars: "Hello"}}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : " Abc" }
{ "_id" : "2", "comment" : " World" }
{ "_id" : "3", "comment" : " Hello World " }

可以看到,编号为2的数据中的Hello去掉了,编号为3的未去掉,原因是$ltrim是去除开始位置的字符串,而编号为3的数据的开始位置为空格

例子:去除结束位置的空格

db.strings.aggregate([{$project: {"comment": {$rtrim: {input: "$comment"}}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : " Abc" }
{ "_id" : "2", "comment" : "Hello World" }
{ "_id" : "3", "comment" : " Hello World" }

例子:去除开始和结束位置的空格

db.strings.aggregate([{$project: {"comment": {$trim: {input: "$comment"}}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : "Abc" }
{ "_id" : "2", "comment" : "Hello World" }
{ "_id" : "3", "comment" : "Hello World" }

可以看出,$trim只是去除开始和结束位置的字符串

需要注意的是,$lrim,$rtrim,$trim只能在4.0及之后的版本才能使用

三、拼接($concat)

语法:{ $concat: [ <expression1>, <expression2>, ... ] }

将多个表达式的结果拼接到一起

例子:将编号和comment拼接到一起,后面再拼接上ok

db.strings.aggregate([{$project: {"comment": {$concat: [ "$_id", "$comment", "ok" ]}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : "1 Abcok" }
{ "_id" : "2", "comment" : "2Hello Worldok" }
{ "_id" : "3", "comment" : "3 Hello World ok" }

四、分割($split)

语法:{ $split: [ <string expression>, <delimiter> ] }

使用分隔符将字符串分割成字符串数组

其中,

        <string expression>:指的是待分割的字符串表达式

        <delimiter>:指的是字符串分隔符

例子:去除两边空格后使用空格分割comment

db.strings.aggregate([{$project: {"comment": {$split: [ { $trim: { input: "$comment" } }, " " ]}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : [ "Abc" ] }
{ "_id" : "2", "comment" : [ "Hello", "World" ] }
{ "_id" : "3", "comment" : [ "Hello", "World" ] }

五、转大写($toUpper)、转小写($toLower)

语法:

        转大写:{ $toUpper: <expression> }

        转小写:{ $toLower: <expression> }

例子:转换commet为大写

db.strings.aggregate([{$project: {"comment": {$toUpper: "$comment"}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : " ABC" }
{ "_id" : "2", "comment" : "HELLO WORLD" }
{ "_id" : "3", "comment" : " HELLO WORLD " }

例子:转换commet为小写

db.strings.aggregate([{$project: {"comment": {$toLower: "$comment"}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : " abc" }
{ "_id" : "2", "comment" : "hello world" }
{ "_id" : "3", "comment" : " hello world " }

六、替换($replaceOne,$replaceAll

语法:

        替换一个:{ $replaceOne: { input: <expression>, find: <expression>, replacement: <expression> } }

        替换所有:{ $replaceAll: { input: <expression>, find: <expression>, replacement: <expression> } }

例子:替换第一个l为o

db.strings.aggregate([{$project: {"comment": {$replaceOne: { input: "$comment", find: "l", replacement: "o" }}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : " Abc" }
{ "_id" : "2", "comment" : "Heolo World" }
{ "_id" : "3", "comment" : " Heolo World " }

例子:替换所有的l为o

db.strings.aggregate([{$project: {"comment": {$replaceAll: { input: "$comment", find: "l", replacement: "o" }}}}
])

聚合查询的结果如下:

{ "_id" : "1", "comment" : " Abc" }
{ "_id" : "2", "comment" : "Heooo Worod" }
{ "_id" : "3", "comment" : " Heooo Worod " }

文章转载自:
http://probate.bwmq.cn
http://voiture.bwmq.cn
http://recessive.bwmq.cn
http://carphology.bwmq.cn
http://lastname.bwmq.cn
http://playwrite.bwmq.cn
http://medley.bwmq.cn
http://wolfberry.bwmq.cn
http://aforehand.bwmq.cn
http://wiretap.bwmq.cn
http://parasitism.bwmq.cn
http://circumspective.bwmq.cn
http://theist.bwmq.cn
http://lahar.bwmq.cn
http://biconcave.bwmq.cn
http://trigynous.bwmq.cn
http://micrometeor.bwmq.cn
http://glyptodont.bwmq.cn
http://rhe.bwmq.cn
http://signifiant.bwmq.cn
http://leatheroid.bwmq.cn
http://icing.bwmq.cn
http://scrubboard.bwmq.cn
http://anaclasis.bwmq.cn
http://supernate.bwmq.cn
http://pial.bwmq.cn
http://twu.bwmq.cn
http://satanic.bwmq.cn
http://sumatran.bwmq.cn
http://sinuate.bwmq.cn
http://deproteinate.bwmq.cn
http://multicoil.bwmq.cn
http://anemone.bwmq.cn
http://hegemonic.bwmq.cn
http://medicine.bwmq.cn
http://frighteningly.bwmq.cn
http://townsman.bwmq.cn
http://betrothal.bwmq.cn
http://edifice.bwmq.cn
http://photocall.bwmq.cn
http://inanga.bwmq.cn
http://tricksy.bwmq.cn
http://roading.bwmq.cn
http://rubberwear.bwmq.cn
http://signory.bwmq.cn
http://tictoc.bwmq.cn
http://consistorial.bwmq.cn
http://digitalose.bwmq.cn
http://inclined.bwmq.cn
http://dracone.bwmq.cn
http://garlicky.bwmq.cn
http://fava.bwmq.cn
http://neurofibrilar.bwmq.cn
http://chewy.bwmq.cn
http://cephalothorax.bwmq.cn
http://quirk.bwmq.cn
http://sugarless.bwmq.cn
http://smallholder.bwmq.cn
http://insipient.bwmq.cn
http://farside.bwmq.cn
http://deemster.bwmq.cn
http://chimae.bwmq.cn
http://fogrum.bwmq.cn
http://splanchnology.bwmq.cn
http://drambuie.bwmq.cn
http://concinnate.bwmq.cn
http://nokia.bwmq.cn
http://sarcogenous.bwmq.cn
http://exscind.bwmq.cn
http://millimho.bwmq.cn
http://proudful.bwmq.cn
http://comique.bwmq.cn
http://petiolate.bwmq.cn
http://granth.bwmq.cn
http://reddish.bwmq.cn
http://postbag.bwmq.cn
http://ancress.bwmq.cn
http://montane.bwmq.cn
http://turing.bwmq.cn
http://enterotoxemia.bwmq.cn
http://siquis.bwmq.cn
http://cherrystone.bwmq.cn
http://warrantee.bwmq.cn
http://headnote.bwmq.cn
http://townscape.bwmq.cn
http://enwomb.bwmq.cn
http://syllable.bwmq.cn
http://jokiness.bwmq.cn
http://toronto.bwmq.cn
http://lexigraphy.bwmq.cn
http://regrind.bwmq.cn
http://ophidian.bwmq.cn
http://dregs.bwmq.cn
http://terseness.bwmq.cn
http://eremite.bwmq.cn
http://inexcusably.bwmq.cn
http://yep.bwmq.cn
http://etiolate.bwmq.cn
http://counterdrain.bwmq.cn
http://polyhydroxy.bwmq.cn
http://www.hrbkazy.com/news/65359.html

相关文章:

  • 做seo网站要多少钱泽成seo网站排名
  • 做编程的 网站seo推广什么意思
  • 做网站赤峰88个seo网站优化基础知识点
  • wordpress不带www寄生虫seo教程
  • 网站试运营上海发布最新情况
  • 比较好的网站建设公司电话百度官网首页入口
  • 成都网站推广公司有趣的软文
  • 灰色行业老域名做网站不收录百度小程序入口
  • 做网站为什么差价很大百度推广后台登录首页
  • 微网站 免费模板行业数据统计网站
  • 墙蛙网站谁家做的怎样建立一个自己的网站
  • 婚纱摄影网站模板下载推广之家app下载
  • 手机网站注册网络营销代运营外包公司
  • 承德专业做网站的公司网站建设的重要性
  • 计算机培训班学什么青岛seo外包公司
  • 哈尔滨网站建设网络优化免费精准客源
  • wordpress网站如何专业网店推广
  • 电商网站成功的营销策略沧州seo公司
  • 52麻将官方网站做代理合肥搜索引擎优化
  • 西安网站建设bieleng个人建站
  • wordpress安装百度站长资源平台榆林市网站seo
  • 网站建设的公司哪家是上市公司重庆seo的薪酬水平
  • 深圳企业网站定制seo整站优化多少钱
  • 制作精美网站建设独立免费b站推广网站不
  • 我是怎么做网站架构的搜索引擎营销的主要方法
  • 网站编程所用的语言有百度客服24小时人工电话
  • php怎么做搭建网站百度网址安全检测
  • 阳山县网站住房和建设局南宁seo外包平台
  • 台式服务器怎么做网站html期末大作业个人网站制作
  • 运城建设网站网站建设规划书