Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery-Regex-需要多个文本中每行的前10个字符_Jquery_Regex - Fatal编程技术网

Jquery-Regex-需要多个文本中每行的前10个字符

Jquery-Regex-需要多个文本中每行的前10个字符,jquery,regex,Jquery,Regex,我有一个多行文本框。此框包含有新换行符的大字符串。我想在多个文本中显示每行或每段的前10个字符。我的多个文本框包含超过10万个字符。使用正则表达式检索字符串是否有最佳解决方案 输入示例: this is sample test I am from australia I am from India 预期输出是每行/每段的前10个字符,后跟… this is sam... I am from a.. I am from I.. 尝试使用此正则表达式查找前10个字符:并替换为$1… output

我有一个多行文本框。此框包含有新换行符的大字符串。我想在多个文本中显示每行或每段的前10个字符。我的多个文本框包含超过10万个字符。使用正则表达式检索字符串是否有最佳解决方案

输入示例:

this is sample test
I am from australia
I am from India
预期输出是每行/每段的前10个字符,后跟

this is sam...
I am from a..
I am from I..

尝试使用此正则表达式查找前10个字符:并替换为
$1…

output = input.replace(/^(.{10})(.*)$/gm, '$0...')
print(output[<line>])
output=input.replace(/^(.{10})(.*)$/gm,$0…)
打印(输出[])
注意,这将与我来自的
匹配␠
而不是
我来自a
,因为它也计算空格。

可能重复的