如何删除数字之间的空格

如何删除数字之间的空格

本文介绍了如何删除数字之间的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好团队

在C#编码中,

i得到的价值就像2365 2365

所以我想删除数字之间的空格.it应该是23652365.i在C#中替换方法和修剪方法之间混淆。如果我使用修剪方法它删除空间但它删除了我不需要的空格之前的数字。我想删除数字之间的空格。我该怎么办?请帮助。



谢谢

Harshal Raut

Hi Team
In C# coding,
i am getting the value as like 2365 2365
so i want to remove the space between numbers.it should be 23652365.i am confuse between Replace method and Trim Method in C#.If i use trim method it remove the space but it remove the number before the space which i dont need.i want to remove the space between the numbers.How should i do this?Kindly help.

Thanks
Harshal Raut

推荐答案

string input = "   2365    2365    ";
string output = Regex.Replace(input, @"(?<=\d+)\s+(?=\d+)", "");



这将删除数字组之间的所有空格并单独留下目的。





使用javascript进行正则表达式是否可行?



是 - 只需使用javascript替换方法:


Which will remove all the spaces between groups of numbers and leave the ends alone.


"is it possible in Regular Expression using javascript?"

Yes - just use the javascript Replace method:

<!DOCTYPE html>
<html>
<body>

<p>Click the button!</p>

<p id="demo">   1234   5678   </p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
var str = document.getElementById("demo").innerHTML;
var res = str.replace(/(\d+)(\s+)(\d+)/,"




这篇关于如何删除数字之间的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 16:08