PHP Split String on Forward Slash Only If It Is Not Preceded By A Backslash
Date : March 29 2020, 07:55 AM
like below fixes the issue Use preg_split (see http://php.net/manual/en/function.preg-split.php). Example: $input = 'Url/Google/http:\/\/www.google.com';
$output = preg_split('|(?<!\\\)/|', $input); //Yes, thats 3 times a backslash
$output = preg_split('|(?<!\\\)/|', $input);
array_walk(
$output,
function(&$item){
$item = str_replace('\\/', '/', $item);
}
);
|
Split string with space and forward slash by forward slash
Tag : chash , By : Mariocki
Date : March 29 2020, 07:55 AM
With these it helps Just use Distinct string[] tokens = value
.Split(new char[] { '/', ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Distinct();
var values = new List<string> { "Cwts", "Rotc", "Lts" };
string[] tokens = value
.Split(new char[] { '/', ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Where(t => values.Contains(t))
.Distinct();
|
split the string containing backward slash and replace with forward slash
Tag : chash , By : Simone
Date : March 29 2020, 07:55 AM
this one helps. I have a string which contains backward slashes and I want to reply it with forward slashes , You original string is not: te\test
te{tab}est
string filename = "te\\test";
var x = filename.Split('\\');
Console.WriteLine(string.Join("/",x));
Console.WriteLine(filename.Replace('\\','/'));
|
how to replace the forward slash to backslash and forward slash using javascript
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I want to replace the "/" into "\/" using javascript. , use replace: "http:/www.freeformatter.com/javascript-escape.html".replace(/\//g, "\\/");
var url = "http:/www.freeformatter.com/javascript-escape.html";
url.replace(/\//g, "\\/");
|
In Powershell 5 what is the best way to parse forward slash and backslash from a string
Date : March 29 2020, 07:55 AM
around this issue In the past, enter a regex to hold the criteria to be replaced in a variable and then replace each occurrence of that criteria: $a_server = "\\\sql2016\"
$a_share = "\temp\"
$criteria = "(/|\\*)" --criteria you want to replace
$a_server = ($a_server -replace $criteria,'')
$a_share = ($a_share -replace $criteria,'')
$Path = "\\$a_server\$a_share"
## $path is now \\sql2016\temp
|