space

How to know if the string variabel contains only space in java?

末鹿安然 提交于 2019-11-29 17:00:46
I have a variable that's a string and I want to replace the string with "null" if the variable contains only a space or multiple spaces. How can I do it? Try the followoing : if(str.trim().isEmpty()){ str = null; } Suppose your variable is String var Then, if(var.replace(" ", "").equals("")) { var = null; } This is a way you could do it: String spaces = " -- - -"; if (spaces.matches("[ -]*")) { System.out.println("Only spaces and/or - or empty"); } else { System.out.println("Not only spaces"); } How about this? if(yourstring.replace(" ","").length()==0) { yourstring = null; } Doesn't need

vbs cmd path space

南楼画角 提交于 2019-11-29 16:15:40
I would like to be able to call the following cmd command from within a vbs script: cmd Client\setupclient.exe /q /targetdir "c:\program files\Microsoft CRM" I came up with the following vbs script: Set oShell = WScript.CreateObject ("WScript.Shell") oShell.Run "cmd /c Client\setupclient.exe /q /targetdir c:\program files\Microsoft CRM", 1, true As far as I am concerned, this would work properly if the targetdir had no spaces, e.g c:\bla. Then the app would be installed in that particular folder. The obvious question is, how can I define the targetdir with spaces as the path location. I tried

System Command with Space in R

随声附和 提交于 2019-11-29 12:48:29
I run a system command with spaces in directory name as followed: command=paste(shQuote("java -jar C:/DIR A/DF.jar -t"), t1, t2) I tried also: command=paste('"java -jar C:/DIR A/DF.jar -t"', t1, t2) However I get the following: Error in system(command, intern = TRUE) : '"java -jar C://DIR A/DF.jar -t"' not found How can I handle space in directory name in Windows? Here is the solution command=paste('java -jar "C:/DIR A/DF.jar" -t', t1, t2) use " only for the dir name and the outside with ' 来源: https://stackoverflow.com/questions/32541926/system-command-with-space-in-r

How to add spaces between number and word in a string in Java?

ε祈祈猫儿з 提交于 2019-11-29 12:24:16
i have a lot of string which contains also number like : LOD140IXAL COMP 1X240GG I would like to put whitespace between numbers and word if there isn't. the number could be every where in the string. One way to do this is using regular expressions. Replacing the following monster with a single space should do the trick: "(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])" When applied to your example ( LOD140IXAL COMP 1X240GG ), it produces LODIXAL COMP 1 X 240 MG . In a nutshell, the regex looks for a letter immediately followed by a digit, or a digit immediately followed by a letter, and inserts

Adding spaces to items in list (Python)

我怕爱的太早我们不能终老 提交于 2019-11-29 11:41:24
I'm a Python noob and I need some help for a simple problem. What I need to do is create a list with 3 items and add spaces before and after every item. For example: l1 = ['a', 'bb', 'c'] should be transformed into: [' a ',' bb ',' c '] I was trying to write something like this: lst = ['a', 'bb', 'c'] for a in lst: print ' a ' ...and so on for the other elements, but I get a syntax error. Can anyone suggest me a working way to do this? Thanks. As always, use a list comprehension : lst = [' {0} '.format(elem) for elem in lst] This applies a string formatting operation to each element, adding

bash: read line and keep spaces

倖福魔咒の 提交于 2019-11-29 11:08:01
I am trying to read lines from a file containing multiple lines. I want to identify lines that contain only spaces. By definition, an empty line is empty and does not contain anything (including spaces). I want to detect lines that seems to be empty but they are not (lines that contain spaces only) while read line; do if [[ `echo "$line" | wc -w` == 0 && `echo "$line" | wc -c` > 1 ]]; then echo "Fake empty line detected" fi done < "$1" But because read ignores spaces in the start and in the end of a string my code isn't working. an example of a file hi hi (empty line, no spaces or any other

export JAVA_HOME with spaces in Cygwin

丶灬走出姿态 提交于 2019-11-29 09:45:21
I'm trying to set my JAVA_HOME in Cygwin with this command: export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.7.0_10" But when I do cd $JAVA_HOME , I'd get this error: $ cd $JAVA_HOME -bash: cd: /cygdrive/c/Program: No such file or directory I tried quoting, and escaping the space (ie., \ ), but none worked. Any idea what else would? Thanks, I faced this problem too and I saw many posts but nothing really worked. There is a small trick that I did and things started working. My JAVA_HOME was set to C:/Program Files/Java/jdk1.7.0_23. The problem was with Program Files directory and I was

Internals of Python list, access and resizing runtimes

倖福魔咒の 提交于 2019-11-28 20:13:47
Is Python's [] a list or an array? Is the access time of an index O(1) like an array or O(n) like a list? Is appending/resizing O(1) like a list or O(n) like an array, or is it a hybrid that can manage O(1) for accessing and resizing? I read here that array access is really slow in Python. However, when I wrote a memoized version of a recursive fibonacci procedure using both a dictionary (Python's dictionary is suppose to be really fast) and a list, they had equal times. Why is this? Does a Python tuple have faster access times than a python list? Eli Bendersky Python's [] is implemented as an

vb.net How to pass a string with spaces to the command line

a 夏天 提交于 2019-11-28 14:00:22
I am trying to call an external program using Process: Dim strExe As String = "E:\Projects\Common Files\mktorrent.exe" Dim p As New Process Dim pinfo As New ProcessStartInfo pinfo.UseShellExecute = False pinfo.RedirectStandardOutput = True pinfo.Arguments = " -a http://blah.com/announce.php -l " & FileSizeMarker & " " & fn pinfo.FileName = strExe pinfo.WorkingDirectory = fn.Substring(0, fn.LastIndexOf("\")) pinfo.WindowStyle = ProcessWindowStyle.Normal pinfo.CreateNoWindow = True p.StartInfo = pinfo p.Start() The problem is with the filename (variable fn above). If it has spaces, the command

Finding the index of a given permutation

做~自己de王妃 提交于 2019-11-28 12:21:15
I'm reading the numbers 0, 1, ..., (N - 1) one by one in some order. My goal is to find the lexicography index of this given permutation, using only O(1) space. This question was asked before, but all the algorithms I could find used O(N) space. I'm starting to think that it's not possible. But it would really help me a lot with reducing the number of allocations. Considering the following data: chars = [a, b, c, d] perm = [c, d, a, b] ids = get_indexes(perm, chars) = [2, 3, 0, 1] A possible solution for permutation with repetitions goes as follows: len = length(perm) (len = 4) num_chars =