spaces

Removing spaces at the end of a string in java [duplicate]

最后都变了- 提交于 2019-12-05 19:22:11
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Strip Leading and Trailing Spaces From Java String When I import data to an application I need to get rid of the spaces at the end of certain strings but not those at the beginning, so I can't use trim()... I've set up a method: public static String quitarEspaciosFinal(String cadena) { String[] trozos = cadena.split(" "); String ultimoTrozo = trozos[trozos.length-1]; return cadena.substring(0,cadena.lastIndexOf

How to prevent MATLAB printing false space and use wrong fonts?

二次信任 提交于 2019-12-05 18:06:22
问题 Matlab 2015a inserts space before µ in long strings, but not in short ones (xlabel). In some cases one can work around by using UTF-8 letters, but this will fail in other situations (see ^2) The font of the text should be Helvetica but it looks different. Although get Fontname returns Helvetica . This is a bug in MATLAB and already reported. I do not want to wait months until MATHWORKS fixes this bug. How can I fix this bug my self? I tried to change the renderer to opengl , but this mixes up

Bash escaping spaces in filename, in variable

旧巷老猫 提交于 2019-12-05 16:41:38
I'm quite new to Bash so this might be something trivial, but I'm just not getting it. I'm trying to escape the spaces inside filenames. Have a look. Note that this is a 'working example' - I get that interleaving files with blank pages might be accomplished easier, but I'm here about the space. #! /bin/sh first=true i=combined.pdf o=combined2.pdf for f in test/*.pdf do if $first; then first=false ifile=\"$f\" else ifile=$i\ \"$f\" fi pdftk $ifile blank.pdf cat output $o t=$i i=$o o=$t break done Say I have a file called my file.pdf (with a space). I want the ifile variable to contain the

Tesseract False Space Recognition

▼魔方 西西 提交于 2019-12-05 05:36:58
I'm using tesseract to recognize a serial number. This works acceptable, common problem like false recognition of zero and "O", 6 and 5, or M and H exists. Beside by this tesseract adds spaces to the recognized words, where no space is in the image. The following image is recognized as "HI 3H" . This image results in " FBKHJ 1R1" So tesseract added a space, although there isn't really a space in the image. Is there a possibility parametrize the spacing behavior of tesseract? Edit I'm sorry, have forgot to add, that I also have serial numbers which include spaces. So I cannot delete all spaces

Remove excess white space from string

偶尔善良 提交于 2019-12-05 05:15:23
I want to remove the excess white spaces using VB.net ex. "The Quick Brown Fox" I want output "The Quick Brown Fox" Thanks, inchika You can use a simple regular expression for that: Dim cleaned As String = Regex.Replace(input, "\s{2,}", " ") I realize that this question is fairly old, but there is another option that doesn't involve Regex, or manually looping through the string and replacing: Private Function StripSpaces(input As String) As String Return String.Join(" ", input.Split(New Char() {}, StringSplitOptions.RemoveEmptyEntries)) End Function And the C# equivalent: private string

PHP preg_replace - www or http://

不想你离开。 提交于 2019-12-05 03:38:27
问题 Really stuck on what seems to be something simple. I have a chatbox/shoutbox where there may be arbitrary URLs entered. I want to find each individual URL (separated by spaces) and wrap it in tags. Example: Harry you're a http://google.com wizard! = Harry you're a $lhttp://google.com$l wizard! Example: Harry you're a http://www.google.com wizard! = Harry you're a $lhttp://www.google.com$l wizard! Example: Harry you're a www.google.com wizard! = Harry you're a $lwww.google.com$l wizard! Sorry

Removing spaces from a variable input using PowerShell 4.0

强颜欢笑 提交于 2019-12-04 15:38:01
问题 I've tried a few things already but they don't seem to work for some reason. Basically what I'm attempting to do is have a user input a value using the "Read-host" cmdlet, then strip it of any spaces. I tried: $answer = read-host $answer.replace(' ' , '""') And: $answer = read-host $answer -replace (' ') I'm probably missing something really obvious, but if anyone could help me out or show me an easier way to achieve this I would appreciate it. I was going to pipeline the variable to a

^a-zA-Z0-9 excluding spaces?

爱⌒轻易说出口 提交于 2019-12-04 11:18:40
问题 I am trying to find everything in a paragraph that is not abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 and not space / /gi /[^a-zA-Z0-9]|[^ ]/gi the above doesn't work! 回答1: You could also try with: /[^a-zA-Z0-9\s]/gi 回答2: If you only want to exclude spaces use: [^ ]* Test the regex here if you want. 回答3: try ^[\d\w]*$ or ^[\w]*$ as reg' Expression means from ^(start) to $(end) match 0-9a-zA-Z only for c++ ansistring="^[\\d\\w]*$"; 回答4: You can use this for am trying to find

bash - Remove all Unicode Spaces and replace with Normal Space

拈花ヽ惹草 提交于 2019-12-04 08:42:13
问题 I have a file with a lot of text, and mixed there are special space characters, those are Unicode Spaces I need to replace all of them with the normal "space" character. 回答1: Easy using perl: perl -CSDA -plE 's/\s/ /g' file but as @mklement0 corectly said in comment, it will match the \t (TAB) too. If this is problem, you could use perl -CSDA -plE 's/[^\S\t]/ /g' Demo: X             X the above containing: U+00058 X LATIN CAPITAL LETTER X U+01680   OGHAM SPACE MARK U+02002   EN SPACE U+02003

Linux - Replacing spaces in the file names

梦想的初衷 提交于 2019-12-04 07:22:10
问题 I have a number of files in a folder, and I want to replace every space character in all file names with underscores. How can I achieve this? 回答1: This should do it: for file in *; do mv "$file" `echo $file | tr ' ' '_'` ; done 回答2: I prefer to use the command 'rename', which takes Perl-style regexes: rename "s/ /_/g" * You can do a dry run with the -n flag: rename -n "s/ /_/g" * 回答3: Use sh... for i in *' '*; do mv "$i" `echo $i | sed -e 's/ /_/g'`; done If you want to try this out before