我正在使用twitter api,下面的字符串正在困扰我Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile

我想把它存储在postgresql中,但不接受\u0000,所以我想替换它。

我试着使用string= string.replaceAll("\\u0000", "");但它不起作用。我只知道String json = TwitterObjectFactory.getRawJSON(user);

System.out.println(json);

json = json.replaceAll("\\u0000", "");

System.out.println(json);

输出(仅重要的部分)

Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile

Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile

如果我把这个部分放在Java中的一个字符串中,替换程序就可以工作了,但是如果我把它放在文本文件中,或者直接在Twitter上读取它,它就不起作用了,所以我的问题是,如何从字符串中替换uUn?

顺便说一下,完整的字符串是

{"utc_offset":null,"friends_count":83,"profile_image_url_https":"https://pbs.twimg.com/profile_images/2636139584/3a8455cd94045fa6980402add14796a9_normal.jpeg","listed_count":1,"profile_background_image_url":"http://abs.twimg.com/images/themes/theme1/bg.png","default_profile_image":false,"favourites_count":0,"description":"Proyecto de ingeniera comercial, actual Profesora de matemáticas \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000Enseña Chile","created_at":"Sat May 28 14:24:06 +0000 2011","is_translator":false,"profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme1/bg.png","protected":false,"screen_name":"Fsquadritto","id_str":"306825274","profile_link_color":"0084B4","is_translation_enabled":false,"id":306825274,"geo_enabled":false,"profile_background_color":"C0DEED","lang":"es","profile_sidebar_border_color":"C0DEED","profile_location":null,"profile_text_color":"333333","verified":false,"profile_image_url":"http://pbs.twimg.com/profile_images/2636139584/3a8455cd94045fa6980402add14796a9_normal.jpeg","time_zone":null,"url":null,"contributors_enabled":false,"profile_background_tile":false,"entities":{"description":{"urls":[]}},"statuses_count":2,"follow_request_sent":false,"followers_count":36,"profile_use_background_image":true,"default_profile":true,"following":false,"name":"Fiorella Squadritto","location":"","profile_sidebar_fill_color":"DDEEF6","notifications":false,"status":{"in_reply_to_status_id_str":null,"in_reply_to_status_id":null,"possibly_sensitive":false,"coordinates":null,"created_at":"Fri Oct 12 17:40:35 +0000 2012","truncated":false,"in_reply_to_user_id_str":null,"source":"Instagram","retweet_count":1,"retweeted":false,"geo":null,"in_reply_to_screen_name":null,"entities":{"urls":[{"display_url":"instagr.am/p/QsOQxTNfvQ/","indices":[49,69],"expanded_url":"http://instagr.am/p/QsOQxTNfvQ/","url":"http://t.co/GKziME7N"}],"hashtags":[{"indices":[24,34],"text":"eduinnova"}],"user_mentions":[{"indices":[35,47],"screen_name":"ensenachile","id_str":"57099132","name":"Enseña Chile","id":57099132}],"symbols":[]},"id_str":"256811615171792896","in_reply_to_user_id":null,"favorite_count":1,"id":256811615171792896,"text":"Amando las matemáticas! #eduinnova @ensenachile http://t.co/GKziME7N","place":null,"contributors":null,"lang":"es","favorited":false}}

最佳答案:

string = string.replace("\u0000", ""); // removes NUL chars

string = string.replace("\\u0000", ""); // removes backslash+u0000

在Java源级上完成了U-逃逸字符。例如,“类”是:

public \u0063lass C {

你也不需要正则表达式。

java u0000_Java-从字符串中删除\ u0000相关推荐

  1. java字符串去掉首尾双引号,Java程序从字符串中删除前导和尾随引号

    首先,让我们考虑一个带引号的字符串String originalStr = "\"Demo Text\""; 现在,请看以下逻辑作为开始引用.if (origi ...

  2. 在Java中从字符串中删除空格

    我有一个像这样的字符串: mysz = "name=john age=13 year=2001"; 我想删除字符串中的空格. 我试过trim()但这只删除了整个字符串前后的空格. ...

  3. 从字符串中删除所有出现的char

    本文翻译自:Remove all occurrences of char from string I can use this: 我可以用这个: String str = "TextX Xt ...

  4. 从字符串中删除HTML标签

    是否有从Java字符串中删除HTML的好方法? 一个简单的正则表达式 replaceAll("\\<.*?>","") 可以使用,但& 不会 ...

  5. 如何从字符串中删除最后一个字符?

    我想从字符串中删除最后一个字符. 我尝试这样做: public String method(String str) {if (str.charAt(str.length()-1)=='x'){str ...

  6. kotlin 字符串去空格_Kotlin程序从字符串中删除所有空格

    kotlin 字符串去空格 Given a string, we have to remove all whitespaces from it. 给定一个字符串,我们必须从中删除所有空格. Examp ...

  7. 如何从字符串中删除文本?

    本文翻译自:How to remove text from a string? I've got a data-123 string. 我有一个data-123字符串. How can I remov ...

  8. 程序员面试题精选100题(36)-在字符串中删除特定的字符[算法]

    题目:输入两个字符串,从第一字符串中删除第二个字符串中所有的字符.例如,输入"They are students."和"aeiou",则删除之后的第一个字符串变 ...

  9. C语言字符串中删除重复的字符的算法(附完整源码)

    C语言字符串中删除重复的字符的算法 C语言字符串中删除重复的字符的算法完整源码(定义,实现,main函数测试) C语言字符串中删除重复的字符的算法完整源码(定义,实现,main函数测试) #inclu ...

  10. 从一个字符串中删除另一个字符串中出现过的字符

    http://blog.csdn.net/walkerkalr/article/details/39001155 定义一个函数,输入两个字符串,从第一个字符串中删除在第二个中出现过的所偶字符串.例如从 ...

最新文章

  1. 智能视觉组赛博 -10赛后反馈
  2. 有线路由器与无线路由器混合使用
  3. 云服务器+开发板搭建直播系统,自建流媒体服务器开直播
  4. php俩个字符串合并,php分割合并两个字符串的函数实例
  5. Guava入门~CharMatcher
  6. 找不到合适的创业路该怎么办
  7. SQLSERVER 清除链接历史记录
  8. 软工课设第一周周四报告
  9. 蓝桥杯省赛2016年Java组B组
  10. 小程序毕设作品之微信小程序点餐系统毕业设计(5)任务书
  11. 计算机输入设备和输出设备怎么区分,输入设备和输出设备的区别
  12. Oracle、聚石塔
  13. Java实体类——entity类的使用与学习
  14. Bootstrap DataTable自定义表格 设置某列不排序
  15. MyBatis自动生成实体类、DAO接口和Mapping映射文件的代码(逆向工程)
  16. 计算机磁盘密码解锁,Bitlocker加密磁盘但是没有密码加密,我的电脑是专业版
  17. Lost in Island
  18. 二年级课程表(3月7日-3月11日)
  19. 使用excel万金油公式的注意事项
  20. 读书印记 - 《反脆弱》

热门文章

  1. 另一种blast2go的思路
  2. i51130g7和i71160g7差多少 酷睿i5 1130G7和i7 1160G7差距
  3. matlab虚拟变量,不要再稀里糊涂的做回归了:如何设置哑变量
  4. 人月到底有多少神话色彩
  5. 用python制作简单节日贺卡
  6. bugkuCTF—杂项—旋转跳跃
  7. HTML网页设计结课作业——基于HTML+CSS仿学校官网页面
  8. pwnable.kr之mistake
  9. 松翰单片机--SN8F5702学习笔记(五)PWM
  10. c语言负数左移右移_C语言负数的移位运算