java - 我想更新其中包含双引号和分号的字符串数据
问题描述
import java.util.*;
class ChangeCSS{
public static void main(String[] args){
System.out.println("Enter the Code to be converted to red css");
Scanner sc=new Scanner("System.in");
String str=sc.nextLine();
//Entered by user String str="<p style="text-align: center;">. <span class="text__white">Techno power</span></p>";
}
}
用户输入上述字符串
我正在尝试将 text__white 更新为 text__red
但是在任何 String 对象中输入上述字符串都会弹出错误
解决方案
您可以在每个特殊字符前面使用正斜杠,如下所示 -
String str="<p style=\"text-align: center;\"><span class=\"text__white\">Techno power</span></p>";
推荐阅读
- javascript - 如何防止反应和socket.io中的无限循环
- reactjs - React Bootstrap导航栏:元素类型无效:需要字符串或类/函数
- reactjs - React Native: how to set different state values from multiple identical child components
- python - How to obtain pagination for the Mongo Aggregate
- python - factoryboy override attribute of lazy_attribute
- vba - 5974 Word Runtime Error 尝试连续使用宏后
- java - How to do a Mongo aggregation query in Spring Data?
- c# - 寻找使这段代码通用的方法
- python - 将直方图的图像转换为直方图值?
- r - Why my script taking more time using data.table compared to data.frame (example given)?