谷歌浏览器内核Cef js代码整理(三) 字符串处理
*字符串截取方法*/
var s="abc_def[ghi]jk[i]";
var temp;
function CopyFromStr(str_source,str_key, bl_containKey)
{
if(str_source.indexOf(str_key)==-1)
{ return "";}
else
{
if(bl_containKey)
{ return str_source.substr(str_source.indexOf(str_key), str_source.length - str_source.indexOf(str_key) + 1);}
else
{ return str_source.substr(str_source.indexOf(str_key)+str_key.length, str_source.length - str_source.indexOf(str_key)+str_key.length + 1);}
}
}
function CopyToStr(str_source,str_key,bl_containKey)
{
if(str_source.indexOf(str_key)==-1)
{ return "";}
else
{
if(bl_containKey)
{ return str_source.substr(0, str_source.indexOf(str_key) + str_key.length);}
else
{ return str_source.substr(0, str_source.indexOf(str_key) );}
}
}
function CopyStr(str_source,str_start,str_end,bl_containStartEnd)
{
var i,j;
var tmp;
tmp = str_source;
i = tmp.indexOf(str_start);
if(i==-1) {return "";}
tmp = CopyFromStr(tmp,str_start,false);
j = tmp.indexOf(str_end);
if(j==-1) {return "";}
if(bl_containStartEnd)
{return str_start + tmp.substr(0, j) + str_end;}
else
{return tmp.substr(0,j);}
}
function CopyStrEx(str_source, str_key, str_start,str_end,bl_containStartEnd)
{
var tmp = str_source;
if((tmp.indexOf(str_key)==-1) ||
(tmp.indexOf(str_start)==-1) ||
(tmp.indexOf(str_end)==-1) )
{return "aaa";}
else
{
tmp = CopyFromStr(tmp,str_key,false);
if(bl_containStartEnd)
{return CopyStr(tmp,str_start,str_end,true);}
else
{return CopyStr(tmp,str_start,str_end,false);}
}
}
function RightFromStr(str_source,str_key,bl_containStartEnd)
{
if(str_source.indexOf(str_key)==-1)
{ return "";}
else
{
while(str_source.indexOf(str_key)>-1)
{str_source = CopyFromStr(str_source,str_key,false);}
if(bl_containKey)
{ return str_key+str_source;}
else
{ return str_source;}
}
}
function RightFromStr(str_source,str_key,bl_containStartEnd)
{
if(str_source.indexOf(str_key)==-1)
{ return "";}
else
{
while(str_source.indexOf(str_key)>-1)
{str_source = CopyFromStr(str_source,str_key,false);}
if(bl_containStartEnd)
{ return str_key+str_source;}
else
{ return str_source;}
}
}
/*调用方法:*/
temp=CopyFromStr(s, '[gh', false);alert(temp);
temp=CopyToStr(s, '[gh', false);alert(temp);
temp=CopyStr(s, '_', '[gh', false);alert(temp);
temp=CopyStrEx(s, '_', '[', ']', false);alert(temp);
temp=RightFromStr(s, '[', false);alert(temp);
谷歌浏览器内核Cef js代码整理(三) 字符串处理的更多相关文章
- 谷歌浏览器内核Cef js代码整理(一)
尊重作者原创,未经作者允许不得转载!作者:xtfnpgy,原文地址: https://www.cnblogs.com/xtfnpgy/p/9285359.html 一.js基础知识 <!-- ...
- 谷歌浏览器内核Cef js代码整理(二) 滚动条
1.隐藏滚动条 document.documentElement.style.overflow = 'hidden';隐藏竖向滚动条:document.documentElement.style.ov ...
- webpages框架使用@razor语法向js代码传递Json字符串
进入web开发时间太短,一个人尝试着做了几个初级项目,遇到了太多的困难.尽管不是学开发专业的,仅为爱好所以硬着头皮坚持了下来. 将遇到的问题记录下来,备查. 使用vs2015中asp.net razo ...
- 常用js代码整理、收集
个人整理了一下个人常用到的一些js代码,以方便学习以及日后使用,或许有一些是个人之前从网上摘下来的,但是不记得是具体从哪里来的了,如果你看到有一段代码跟你的文章很相似甚至一样,请不要气愤,请告诉我,我 ...
- c#: WebBrowser控件注入js代码的三种方案
聊做备忘. 假设js代码为: string jsCode = @"function showAlert(s) {{ alert('hello, world! ' + s);}}; showA ...
- 常用JS代码整理
1: function request(paras) { 2: var url = location.href; 3: var paraString = url.substring(url.index ...
- 判断点击第几个按钮JS代码的三种方法
方法一:使用下标实现<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...
- JS代码把JSON字符串转换为对象,计算对象的长度并把它转换为数字类型,把转换的值相加减
Number(JSON.parse(rowObject.RenewalProperty).length)-1
- 【JS学习】-利用谷歌浏览器调试JS代码(转)
谷歌浏览器是常用来调试JS代码的工具,本文主要介绍如何利用谷歌浏览器来调试JS代码,协助我们进行开发工作. 首先,打开谷歌浏览器,按快捷键F12或者ctrl+shift+j,就可以打开谷歌浏览器的开发 ...
随机推荐
- Chained Exceptions in Java
1. Overview In this article, we’ll have a very brief look at what Exception is and go in depth about ...
- Go程序设计
01 Go基础特性&独有特性
- 调用 LoadLibraryEx 失败,在 ISAPI 筛选器 "C:\Program Files\php\php5isapi.dll"
把 ISAPI 筛选器这里的php配置删掉,php改用fastcgi配置
- js的去重
1.ES6 : set 注set的坑: 类数组转为数组,ES6提供了Array.from的方式,但在ES5中,类数组可以通过[].sclice.call(likeArr)转换,但对set无效 如:va ...
- Java 1.7 NQuery
package org.rx.common; import java.lang.reflect.Array; import java.util.*; /** * Created by wangxiao ...
- unity3d平铺图片
using System;using System.Linq;using System.Text;using System.Reflection;using System.Collections;us ...
- xpath提取到的中文乱码时的解决办法
βҳ转换为正常的中文:
- L2-014. 列车调度(set)*
L2-014. 列车调度 参考博客 #include <iostream> #include <cstdio> #include <set> #include &l ...
- How Region Split works in Hbase
A region is decided to be split when store file size goes above hbase.hregion.max.filesize or accord ...
- POI导出Execl文件,使JAVA虚拟机OOM
由于在项目中使用POI导出execl,导致JAVA虚拟机OOM,采用以下方式解决问题: 原先方式: g_wb = new XSSFWorkbook(sourceFile.getInputStream( ...