Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
I'm experimenting with command line arguments in Rust.
Windows Power Shell.
if let Some(a) = env::args().nth(1) {
println!("parâmetro é {:?}", &a);
} else ...
ARG = "Qu'il" prints "parâmetro é Qu\'il" (ok)
ARG = Qu'il (results in apparent infinite loop)
ARG = Qu\il (idem)
So, what's the proper way to handle this (the error)?
Thanks in advance.
I can't really discern what error you are referring to, so I'll explain the reasoning for the behavior you are seeing:
You are using the format specifier {:?} which makes Rust print the string in a debug-friendly manner. If you use println!("parâmetro é {}", &a); instead you'd see parâmetro é Qu'il
This is not an infinite loop. Apostrophes (') are special characters in PowerShell to define a literal string. The reason why nothing is happening is that PowerShell is waiting for you to write the rest of the string and finish with another apostrophe.
Like nr. 1
See more here:
About literal strings in PowerShell
Can I use a single quote in a PowerShell 'string'?
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I need to replace certain letters in a word with a character.
I'm stuck. How can I fix it?
It looks like you already have most of the code. You just need to add the letters that don't need to be replaced and are not in the consonants list.
To do this, I would use an if-else instead of an if in your loop. This will allow you to replace letters that are in the consonants list and add letters that don't need to be replaced to the final word.
It would look something like this:
Note that the consonants list has the characters that are to be replaced in word word.
This should give you what you are looking for.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to append lines to the previous line if the blank line is followed by the line.
For example:
A
B
C
1
D
E
B
Ouput:
A
B
C
1D
EB
See also Håkon Hægland's comment above. This is one of those problems that lends itself to treating the whole file as one long string (with embedded newline characters). Perl has a flag -0 for changing or turning off the default "record separator" definition that accomplishes this. Then you just need to realize that, depending on your definition of "blank line", you seem to be requesting that all sequences of two or more newline characters in a row simply be removed. (If your definition of "blank line" can include lines with blank characters on them (whitespace, i.e. spaces and tabs), you'll need a more complicated expression.) This compact one-liner will do it:
$ perl -0pe 's/\n\n+//g' blanklines
A
B
C
1D
EB
Now please tell me this was not a homework assignment.
Update: I realized a couple of additional things. 1) Since newline is included in Perl's whitespace special escape \s, expanding to handle the case of blank lines having blank characters on them is not really more complex: perl -0pe 's/\n\s+//g' blanklines. 2) There is an edge case that this solution doesn't handle right: blank lines at the end of the input. I'll leave that as a problem for the student. :-)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I'm using following regex to validate name:
^[a-zA-Z]{1}[a-zA-Z.' ]{1,20}$
Single quote is mentioned in the second range. However, when I validate a string against this regex, single quote (') invalidates the match. Here's my code:
let nameRegEx = "^[a-zA-Z]{1}[a-zA-Z.' ]{1,21}$"
let nameTest = NSPredicate(format:"SELF MATCHES %#", nameRegEx)
let isNameValid = nameTest.evaluate(with: name)
I've tried \' but no use.
Turns out textField.text returns ’ and not '. Changing the character resolved the issue.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have made a document based program lately.
But what intrigues me that how can a compiler(in my case, objective-c) convert any character into Unicode so fast while these characters are only visual presentations.
I think maybe A~Z and all other common characters can be converted from ASCII to Unicode very easily. What about other special character such as brand icon and copyright icon?
I am solely interested in the internal working of such conversion.
Example:
How do compiler understand what "©" is in a blink of second? Is it by looking up a UNICODE table? But if I have 1000000 "©", does my compiler look them up in the table 1000000 times? That is very time consuming, isn't it?
The compiler doesn't see "©". It sees whatever numerical representation of "©" occurs in the source file it's processing. No lookup is needed, because it's already in the form the compiler uses. (Some conversions might be needed if, for example, the source file is in UTF-8 and the compiler uses UTF-32 internally, but such conversions don't require a full Unicode table.)
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Do you know how to look for special characters with google...?
I'm looking at bash code and there's the ## operator. I would like to know what It does but I wasn't able to figure out a way to protect the character (I'm not sure it's even possible).
This is particularly annoying when you're looking for some code patterns, some characters are always ignored.
Update: this answer is no longer applicable as of 2017. See https://blog.google/products/search/improvements-searching-special-characters-programming-languages/
Google strips most punctuation from queries, as described here, so it won't help you with the bash syntax.
It's very easy to search for the string "##" in the bash documentation: Just run "info bash", hit "s", and enter "##" as the search string.
google strips puntuation, imho, because:
it's somewhere used for special search (chars like - to exclude, +to add and 10..20 to specify a range)
to avoid spammers to get email addresses (characters like # or .)
in my experience, it's even impossible to escape special characters.
the only solution I found, by now, is using yahoo http://it.search.yahoo.com/