character

Java: Print a unique character in a string

戏子无情 提交于 2019-12-30 05:05:47
问题 I'm writing a program that will print the unique character in a string (entered through a scanner). I've created a method that tries to accomplish this but I keep getting characters that are not repeats, instead of a character (or characters) that is unique to the string. I want the unique letters only. Here's my code: import java.util.Scanner; public class Sameness{ public static void main (String[]args){ Scanner kb = new Scanner (System.in); String word = ""; System.out.println("Enter a

Swift How to get integer from string and convert it into integer

淺唱寂寞╮ 提交于 2019-12-29 20:10:22
问题 I need to extract numbers from string and put them into a new array in Swift. var str = "I have to buy 3 apples, 7 bananas, 10eggs" I tried to loop each characters and I have no idea to compare between Characters and Int. 回答1: First, we split the string so we can process the single items. Then we use NSCharacterSet to select the numbers only. import Foundation let str = "I have to buy 3 apples, 7 bananas, 10eggs" let strArr = str.split(separator: " ") for item in strArr { let part = item

unescape unicode from input

删除回忆录丶 提交于 2019-12-29 09:19:09
问题 I am reading line by line from standard input with Scanner, then i print these lines to standard output. But, i need to convert escaped Unicode characters like \u00fd to actual character. Is there any way how to do it? 回答1: I recommend http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/StringEscapeUtils.html. 来源: https://stackoverflow.com/questions/5479728/unescape-unicode-from-input

Invalid character range error in a new function [duplicate]

我的未来我决定 提交于 2019-12-29 08:08:29
问题 This question already has answers here : Is the regular expression [a-Z] valid and if yes then is it the same as [a-zA-Z]? (7 answers) Closed 2 months ago . I have a problem with the follwoing error message invalid regular expression '([a-Z]*)_(.*)', reason 'Invalid character range' so the line of code which causes the error is if(tide=="long") names(problem) <- sub("([a-Z]*)_(.*)","\\2",problem) so if long is selected for the parameter tide in the function the names of problem shall be

Why stringbuilder stops adding elements after using the null character?

微笑、不失礼 提交于 2019-12-29 06:47:55
问题 When i am using the null character '\u0000' , stringbuilder will stop appending new elements. For example: StringBuilder _stringBuilder = new StringBuilder(); _stringBuilder.append('\u0000'); _stringBuilder.append('a'); System.out.println("."+_stringBuilder+"."); returns . I understand that the null value should not be printed (or printed like if it was a null String value) but in this case, why does stringbuilder is failing to add more elements ? Note: I am using jdk 1.6.0_38 on ubuntu. 回答1:

Removing leading zeros from alphanumeric characters in R

拜拜、爱过 提交于 2019-12-29 06:44:09
问题 I have a character vector d with alphanumeric characters d <- c("012309 template", "separate 00340", "00045", "890 098", "3405 garage", "matter00908") d [1] "012309 template" "separate 00340" "00045" "890 098" "3405 garage" "matter00908" How can I remove the leading zeros from all the numbers in R? as.numeric will remove all leading zeros only in numeric or integer vectors. I have tried gsub with regex but could not get the desired results. The expected output is as follows out <- c("12309

How to replace special characters with their equivalent (such as “ á ” for “ a”) in C#?

百般思念 提交于 2019-12-29 05:21:50
问题 I need to get the Portuguese text content out of an Excel file and create an xml which is going to be used by an application that doesn't support characters such as "ç", "á", "é", and others. And I can't just remove the characters, but replace them with their equivalent ("c", "a", "e", for example). I assume there's a better way to do it than check each character individually and replace it with their counterparts. Any suggestions on how to do it? 回答1: You could try something like var

How do i read single character input from keyboard using nasm (assembly) under ubuntu?

有些话、适合烂在心里 提交于 2019-12-28 18:06:33
问题 I'm using nasm under ubuntu. By the way i need to get single input character from user's keyboard (like when a program ask you for y/n ?) so as key pressed and without pressing enter i need to read the entered character. I googled it a lot but all what i found was somehow related to this line ( int 21h ) which result in "Segmentation Fault". Please help me to figure it out how to get single character or how to over come this segmentation fault. 回答1: It can be done from assembly, but it isn't

How do i read single character input from keyboard using nasm (assembly) under ubuntu?

↘锁芯ラ 提交于 2019-12-28 18:06:12
问题 I'm using nasm under ubuntu. By the way i need to get single input character from user's keyboard (like when a program ask you for y/n ?) so as key pressed and without pressing enter i need to read the entered character. I googled it a lot but all what i found was somehow related to this line ( int 21h ) which result in "Segmentation Fault". Please help me to figure it out how to get single character or how to over come this segmentation fault. 回答1: It can be done from assembly, but it isn't

SQL Server TRIM character

我是研究僧i 提交于 2019-12-28 13:46:45
问题 I have the following string: 'BOB*', how do I trim the * so it shows up as 'BOB' I tried the RTRIM('BOB*','*') but does not work as says needs only 1 parameter. 回答1: LEFT('BOB*', LEN('BOB*')-1) should do it. 回答2: Another pretty good way to implement Oracle's TRIM char FROM string in MS SQL Server is the following: First, you need to identify a char that will never be used in your string, for example ~ You replace all spaces with that character You replace the character * you want to trim with