|
Given a string file path such as "/foo/fizzbuzz.bar" how would I use bash to extract just the "fizzbuzz" portion of said string?
Started by Lawrence Johnston on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
It will also remove....
Echo '/foo/fizzbuzz.bar' | sed 's the path.
ARGV[0]; ($path,$name) = $fullname =~ /^(.*[^\\]\/)*(.*)$/; ($basename,$extension) = $name the wanted string and replacing the input with the wanted string.
|
|
I have a string that represents a path to a directory. I want split the string if it is a unix type path or a ms-dos type path.
How can this be done?
For example:
<?php $a = some_path1/some_path2/some_path3; // unix type path $b = some_path1\some_path...
Answer Snippets (Read the full thread at stackoverflow):
Edit:
If you know what type of path you've got/dir.constants.php
First, it seems to me that preg....
Your regex would be
preg_split('_[\\\\/]_', $a);
The backslashes are escaped once for the string and again for the regular expression engine.
|
|
I have a string with quotes around the path as follows:
"C:\Program Files (x86)\Windows Media Player\wmplayer.exe" arg1 arg2
If I use Text.Split(new Char[] { ' ' }, 2); then I get the first space.
How to get the path and args ?
Started by Kaya on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
string[] pathAndArgs = Text.Split(new Char[] { '/"' }, 3); string[] args = pathAndArgs[2].Split(new Char[] { ' ' }, 2);
I may have a syntax.
The last string in that array and splitting again on the space.
|
Ask your Facebook Friends
|
Is there a standard way to do an fopen with a unicode string file path?
Started by Brian R. Bondy on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
CTYPE="en_US.UTF-8"
The encoding of file paths is normally set system wide, so if your file path, or in this forum ) In windows, you can use _wfopen, and then pass a unicode string (for more information, see MSDN.
|
|
I have a string that may have a path to a file. Example src="/folder/whatever". How do I replace that path with src="http://www.sitename.com/folder/whatever ?
Started by Rafal on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If your string contains src="/..." , possibly many times, do this:
string.gsub!(/\bsrc="(\/[^"]*)"/, 'src="http://www.sitename.com\1"')
If your string contains the URL only, do this:
src.replace('http://www.sitename.com' + src)
More information....
|
|
What's the best way, using C# or other .NET language, to determine if a file path string is on the local machine or a remote server?
It's possible to determine if a path string is UNC using the following:
new Uri(path).IsUnc
That works great for paths...
Started by David on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
You can get the local machine name using:
string hostName = System.Net.Dns.GetHostName()
You can then get an array of IP addresses by passing that string.
To either the local host name or IP address.
|
|
In my new code I am not using strings to pass directory paths or file names. Instead I am using DirectoryInfo and FileInfo as they seem to encapsulate a lot of information.
I have seen a lot of code that uses strings to pass directory information then...
Answer Snippets (Read the full thread at stackoverflow):
Not in a plain text configuration file), no, there isn't if all you need is a path.....
Where I would (potentially) pass a path as as a string instead of using FileInfo and DirectoryInfoOnce the path is in an application (i.e.
|
|
I have developed a number of classes which manipulate files in Java. I am working on a Linux box, and have been blissfully typing new File("path/to/some/file"); . When it came time to commit I realised some of the other developers on the project are using...
Started by Grundlefleck on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Apache io source code :
public static String separatorsToSystem(String path) { if (path == null the string that represents the path?
shouldn't it be enough to say: "path"+File.Seperator and is worth ....
|
|
Is there a builtin function in php to intelligently join path strings?
Like path_join("abc/de/","/fg/x.php") which should return "abc/de/fg/x.php" , but path_join("abc/de","fg/x.php") should have the same result
If not, is there a class availabel. Could...
Answer Snippets (Read the full thread at stackoverflow):
Feel free to make a function path snippets as you want, either as array or separate arguments:
function joinPaths() { $args); } foreach ($paths as &$....
Be a path with no slashes at the beginning or end and no double slashes within.
|
|
I've seen similar questions and answers regarding conversions from virtual to absolute and url, but how can I convert a url to a virtual path without manual string parsing?
Example:
I want "http://myserver/home.aspx" converted to: "~/home.aspx"
I realize...
Started by Kilhoffer on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I didn't find a way without manual string").AbsolutePath);
VirtualPathUtility.ToAppRelative Method (String) seems to be what you are looking for ( http://msdn.microsoft....
The resulting application-relative path is "~/sub/default.aspx".
|