Questions tagged [slash]

Please do not use this tag. The / character ("forward slash", or just "slash") is a directory separator in URLs and in many operating systems including Linux (Windows uses \ (backslash) but many applications and APIs also accept /). It is also the division operator in many languages, and marks closing tags in XML/HTML. In some languages, / characters delimit regular expressions.

The slash character / (sometimes called forward slash to distinguish it from \ ) has several common meanings in computing:

  • / is the directory separator in file names on Unix-like and POSIX operating systems, including Linux. Many Windows APIs and applications accept / as a directory (folder) separator, although some require a backslash \ instead. / is also the directory separator in URLs.
  • In many programming languages, / is the division operator . When applied to integers, / returns the quotient of the division in many languages.
  • In SGML based languages including and , / marks closing tags, as in <b>bold</b> or <br />.
  • / is a common delimiter for regular expressions searches (in , , , etc.).
465 questions
193
votes
12 answers

Get value of a string after last slash in JavaScript

I am already trying for over an hour and cant figure out the right way to do it, although it is probably pretty easy: I have something like this : foo/bar/test.html I would like to use jQuery to extract everything after the last /. In the example…
r0skar
  • 8,338
  • 14
  • 50
  • 69
181
votes
7 answers

Difference between forward slash (/) and backslash (\) in file path

I was wondering about the difference between \ and / in file paths. I have noticed that sometimes a path contains /and sometimes it is with \. It would be great if anyone can explain when to use \ and /.
Spider man
  • 3,224
  • 4
  • 30
  • 42
158
votes
8 answers

Is it possible to use "/" in a filename?

I know that this is not something that should ever be done, but is there a way to use the slash character that normally separates directories within a filename in Linux?
subcan
  • 2,021
  • 2
  • 18
  • 21
67
votes
5 answers

Replace slash in Bash

Let's suppose I have this variable: DATE="04\Jun\2014:15:54:26" Therein I need to replace \ with \/ in order to get the string: "04\/Jun\/2014:15:54:26" I tried tr as follows: echo "04\Jun\2014:15:54:26" | tr '\' '\\/' But this results in:…
user109447
  • 1,069
  • 1
  • 10
  • 20
51
votes
11 answers

Remove a trailing slash from a string(changed from url type) in JAVA

I want to remove the trailing slash from a string in Java. I want to check if the string ends with a url, and if it does, i want to remove it. Here is what I have: String s = "http://almaden.ibm.com/"; s= s.replaceAll("/",""); and this: String s…
Eswar Rajesh Pinapala
  • 4,841
  • 4
  • 32
  • 40
46
votes
5 answers

Change backslash to forward slash in windows batch file

I'm trying to convert all backslashes () to forward slashes (/) in a variable which contains a file name and location. I've read about this and seen: %variable:str1=str2% and set "var=%var:\=/%" which I've attempted, but I'm obviously not getting…
user3253319
  • 535
  • 1
  • 5
  • 8
43
votes
9 answers

Python Replace \\ with \

So I can't seem to figure this out... I have a string say, "a\\nb" and I want this to become "a\nb". I've tried all the following and none seem to work; >>> a 'a\\nb' >>> a.replace("\\","\") File "", line 1 a.replace("\\","\") …
kand
  • 2,268
  • 6
  • 31
  • 43
28
votes
2 answers

Why is the slash an escapable character in JSON?

json.org states, that forward slashes (aka solidus, /) can be escaped: "\/" However, unescaped slashes are valid, too: "/" What's the rational behind this? Does it come from the Javascript roots? (I.e., "" is a problem in browser-based…
Boldewyn
  • 81,211
  • 44
  • 156
  • 212
25
votes
11 answers

Adding Firebase data, dots and forward slashes

I try to use firebase db, I found very important restrictions, which are not described in firebase help or FAQ. First problem is that symbol: dot '.' prohibited in keys, i.e. firebase reject (with unknown reason) next: …
IL55
  • 910
  • 1
  • 9
  • 15
22
votes
3 answers

How do you grep for a string containing a slash?

How should I grep for a string containing a forward slash like ./.?
LookIntoEast
  • 8,048
  • 18
  • 64
  • 92
21
votes
4 answers

Add Trailing Slash .htaccess

I'm trying to get the following effect (using this local file http://localhost/[company_name]/[project_name]/.htaccess): http://localhost/[company_name]/[project_name]/page-1 (adds slash) http://localhost/[company_name]/[project_name]/page-1/ (does…
Simon
  • 5,464
  • 6
  • 49
  • 85
20
votes
4 answers

Forward slash or backslash?

I am looking to write and read text files to and from (respectively) a directory different from that of my program. When I specify a directory to write to or read from, should I be using forward slashes or backslashes to identify a file path?
Patriot524
  • 201
  • 1
  • 3
  • 7
20
votes
7 answers

Issue In Removing Double Or More Slashes From URL By .htaccess

I am using the following htaccess rul to remove double or more slashes from web urls: #remove double/more slashes in url RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ RewriteRule . %1/%2 [R=301,L] This is working fine for slashes occured in the middle of…
Rana
  • 5,912
  • 12
  • 58
  • 91
20
votes
2 answers

Odd C# path issue

My C# application writes its full path surrounded by double quotes to a file, with: streamWriter.WriteLine("\"" + Application.ExecutablePath + "\""); Normally it works, the written file contains "D:\Dev\Projects\MyApp\bin\Debug\MyApp.exe" But, if…
Ryan
  • 257
  • 2
  • 4
19
votes
4 answers

What is the difference between using "new RegExp" and using forward slash notation to create a regular expression?

Is there any difference between using new RegExp("regex"); and /same_regex/ to test against a target string? I am asking this question because I got different validating result while use these two approaches. Here is the snippet I used to validate…
didxga
  • 5,935
  • 4
  • 43
  • 58
1
2 3
30 31