字符串截取,
英文单词单数复数转换(Agile Web Development with Rails [Chapter 15||||||||||||||Active Support[P251])
ruby 代码
- string = "Now is the time"
- puts string.at(2)
- puts string.from(8)
- puts string.to(8)
- puts string.first
- puts string.first(3)
- puts string.last
- puts string.last(4)
- puts string.starts_with?("No" )
- puts string.ends_with?("ME" )
- count = Hash.new(0)
- string.each_char {|ch| count[ch] += 1}
- puts count.inspect
- "e" =>2, "h" =>1, "s" =>1, "t" =>2, "i" =>2}
- Active Support adds methods to all strings to support the way Rails itself
- converts names from singular to plural, lowercase to mixed case, and so on. A
- few of these might be useful in the average application.
- "cat".pluralize
- puts
- "cats".pluralize
- puts
- "erratum".pluralize
- puts
- "cats".singularize
- puts
- "errata".singularize
- puts
- "first_name".humanize
- puts
- "now is the time".titleize
- puts
ruby 代码
- =begin
-
- hash={"previous"=>nil, "operateDescription"=>nil, "channel_status"=>["E", "R", "P", "Q"], "next"=>nil, "lastOperator"=>nil}
- arr_need=['previous','operateDescription','channel_status','next','lastOperator']
- arr_del=['lastOperator','next']
- hash_after=StringArray.hsh_delete_if(hash,arr_need,arr_del) => {"previous"=>nil, "operateDescription"=>nil, "channel_status"=>["E", "R", "P", "Q"]}
- =end
- def self.hsh_delete_if(hash,arr_need,arr_del)
- hash.delete_if do |key,value|
- !arr_need.include?(key) or arr_del.include?(key)
- end
- return hash
- end
-
- =begin
-
- hash=["previous", "operateDescription", "channel_status", "next", "lastOperator"]
- arr_need=['previous','operateDescription','channel_status','next','lastOperator']
- arr_del=['lastOperator','next']
- hash_after=StringArray.arr_delete_if(hash,arr_need,arr_del) => {"previous"=>nil, "operateDescription"=>nil, "channel_status"=>["E", "R", "P", "Q"]}
- =end
- def self.arr_delete_if(array,arr_need,arr_del)
- array.delete_if do |value|
- !arr_need.include?(value) or arr_del.include?(value)
- end
- return array
- end
分享到:
相关推荐
Plus.stringString manipulation extensions for Plus.js javascript library._.string.capitalize(str)字符串首字母大写。_.string.capitalize('foo');=> 'Foo'_.string.titleize(str)字符串所有单词大写。_.string...
当您使用WhatsApp Web时,它将使句子的首字母大写。 使用步骤: 下载此回购并提取 打开谷歌浏览器 打开以下网址chrome:// extensions / 启用开发人员模式 单击LOAD UNPACKED按钮并选择下载的目录 在新标签页中...
Although building native Ruby C extensions on Windows has historically been a problem, we believe the combination of our One-Click Ruby Installer, our development tools, and the growing community of ...
Ruby C Extensions Ruby C Extensions Ruby C Extensions
不管是什么,首字母缩写词解码器(AD!)旨在帮助您理解字母汤。 这是一个相当简单的工具,突出显示您具有定义的单词,然后让您通过单击鼠标拉出这些定义。 运行本地服务器 npm install gulp 在Chrome浏览器上...
运行报错没有typing_extensions模型的时候,下载typing_extensions.py放到typing.py同级目录即可!
Transform your existing web applications into Google Chrome browser extensions and create brand new extensions that improve your own browsing experience and that of your users. This book shows you how...
Extensions to RxJava This library allow simple implementation for some tasks in android Usage Add library to project dependencies. repositories { maven { url "https://jitpack.io" } } dependencies {...
Parser Error Message: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 系统找不到指定的文件。 ...
可以让你的 Windows 支持显示大部分主流视频格式文件的预览缩略图,其中包括 mkv、flv、avi、mp4、mov、rmvb、m2ts、ogm 等,可以说Icaros Shell Extensions是一款很好转换工具 Icaros Shell Extensions(视频扩展器...
Spring Data JDBC Extensions API。 Spring Data JDBC Extensions 开发文档
Hibernate-extensions 完整无损安装包,谁用谁知道
GitExtensions-2.50.01 破解版,GitExtensions-2.50.01 破解版
许多朋友下载Ajax源码后无法运行,需要System.Web.Extensions.dll和System.Web.Extensions.Design.dll 这2个DLL文件,发给需要的朋友!
Transform your existing web applications into Google Chrome browser extensions and create brand new extensions that improve your own browsing experience and that of your users. This book shows you how...
####如何将Guid string值转换为Guid类型? 假设我们将 guid 值作为字符串存储在数据库中。 当我们要在.Net端使用时,首先要解析。 Guid guid_AsValid = " 63ba52b5-1dd5-4b26-ba27-83f62c3d7e48 " . To (); // As...
Extensions of Compressed Sensing with matlab
rxjs Reactive Extensions for javascript Reactive Extensions for javascript