special-characters

Remove special characters in the string in java?

夙愿已清 提交于 2019-12-01 09:38:21
问题 How to remove special characters in the string except "- _". Now I use: replaceAll("[^\\w\\s]", "") it remove all special character but i want to keep "- _" . Can anyone tell me how should I do? 回答1: Use replaceAll("[^\\w\\s\\-_]", ""); What I did was add the underscore and hyphen to the regular expression. I added a \\ before the hyphen because it also serves for specifying ranges: a-z means all letters between a and z. Escaping it with \\ makes sure it is treated as an hyphen. 回答2: This

Special and accented characters

谁说胖子不能爱 提交于 2019-12-01 09:28:46
I am doing some work for a French client and so need to deal with accented characters. But I'm running into a lot of difficulty, I am hoping the solution is simple and that somebody can point it out to me. The string: La Forêt pour Témoin is converted to: La For? pour T?oin Note the missing character following the accented character - the t following the ê and the m following the é . I have tried using StringEscapeUtils which was successful at escaping some characters, such as ă . I have also built my own escape function which produces the same results ( ă will work, ê will not). private

PHP: Explode using special characters

≯℡__Kan透↙ 提交于 2019-12-01 05:27:30
I'm working on a long string grabbed from a Session that uses "§" (Section sign) to group and divide different parts of the string. Example: "ArticleID | Title | Date § ArticleID | Title | Date § ArticleID | Title | Date" I want to put this into an array using: explode("§",$str); However, for some reason the character is totally ignored. I have simply used a different character instead to get this working but why does PHP not recognise it? Check the file encoding. This § can be being passed to explode() as "\xA7", "\xA7\x00" or "\xC2\xA7" depending if the PHP file is encoded as ASCII, UNICODE

how check if String has Full width character in java

最后都变了- 提交于 2019-12-01 04:40:50
Can anyone suggest me how to check if a String contains full width characters in Java ? Characters having full width are special characters. Full width characters in String: abc@gmail.com Half width characters in String: abc@gmail.com I'm not sure if you are looking for any or all, so here are functions for both: public static boolean isAllFullWidth(String str) { for (char c : str.toCharArray()) if ((c & 0xff00) != 0xff00) return false; return true; } public static boolean areAnyFullWidth(String str) { for (char c : str.toCharArray()) if ((c & 0xff00) == 0xff00) return true; return false; } As

PHP 5.6 upgrade and special characters

耗尽温柔 提交于 2019-12-01 04:39:12
I have a website where I've used php to include sections rather than having code be duplicated for each page. However, recently my webhost upgraded the PHP to 5.6, and now all my Æ, Ø and Å's give me the replacement character (�). I'm not running any databases, and setting a charset in the html didn't help. I'm very inexperienced with PHP, so I have no idea how to fix it. Please, any help would be great! I had the same problem after upgrading from php 5.5. to 5.6. Solved it by setting the default_charset to an empty string in my script: ini_set("default_charset", ""); Or if you have acceess to

fread from data.table package when column names include spaces and special characters?

情到浓时终转凉″ 提交于 2019-12-01 03:26:58
I have a csv file where column names include spaces and special characters. fread imports them with quotes - but how can I change this behaviour? One reason is that I have column names starting with a space and I don't know how to handle them. Any pointers would be helpful. Edit: An example. > packageVersion("data.table") [1] ‘1.8.8’ p2p <- fread("p2p.csv", header = TRUE, stringsAsFactors=FALSE) > head(p2p[,list(Principal remaining)]) Error: unexpected symbol in "head(p2p[,list(Principal remaining" > head(p2p[,list("Principal remaining")]) V1 1: Principal remaining > head(p2p[,list(c(

how check if String has Full width character in java

烈酒焚心 提交于 2019-12-01 03:23:24
问题 Can anyone suggest me how to check if a String contains full width characters in Java ? Characters having full width are special characters. Full width characters in String: abc@gmail.com Half width characters in String: abc@gmail.com 回答1: I'm not sure if you are looking for any or all, so here are functions for both: public static boolean isAllFullWidth(String str) { for (char c : str.toCharArray()) if ((c & 0xff00) != 0xff00) return false; return true; } public static boolean

PHP: Explode using special characters

被刻印的时光 ゝ 提交于 2019-12-01 03:03:31
问题 I'm working on a long string grabbed from a Session that uses "§" (Section sign) to group and divide different parts of the string. Example: "ArticleID | Title | Date § ArticleID | Title | Date § ArticleID | Title | Date" I want to put this into an array using: explode("§",$str); However, for some reason the character is totally ignored. I have simply used a different character instead to get this working but why does PHP not recognise it? 回答1: Check the file encoding. This § can be being

What is the best way to remove punctuation marks, symbols, diacritics, special characters?

99封情书 提交于 2019-12-01 02:45:26
I use these lines of code to remove all punctuation marks, symbols, etc as you can see them in the array, $pattern_page = array("+",",",".","-","'","\"","&","!","?",":",";","#","~","=","/","$","£","^","(",")","_","<",">"); $pg_url = str_replace($pattern_page, ' ', strtolower($pg_url)); but I want to make it simpler as it looks silly to list all the stuff I want to remove in the array as there might be some other special characters I want to remove. I thought of using the regular expression below, $pg_url = preg_replace("/\W+/", " ", $pg_url); but it doesn't remove under-score - _ What is the

What is the backslash(\) used for in SwiftUI?

醉酒当歌 提交于 2019-12-01 02:22:53
问题 In the Apple tutorial for SwiftUI called "Composing Complex Interfaces", the tutorial uses a backslash that doesn't appear to be string interpolation or an escape character. This is the line: ForEach(categories.keys.sorted().identified(by: \.self)) What is the purpose of this backslash? Below is the entire Struct that contains it. struct CategoryHome: View { var categories: [String: [Landmark]] { .init( grouping: landmarkData, by: { $0.category.rawValue } ) } var body: some View {