我有一个需要解析的文本区域.需要拔出每个新线路并且需要对其执行操作.操作完成后,需要在下一行运行操作.这就是我现在所拥有的.我知道indexOf搜索不起作用,因为它逐个字符地搜索.
function convertLines()
{
trueinput = document.getElementById(8).value; //get users input
length = trueinput.length; //getting the length of the user input
newinput=trueinput; //I know this looks silly but I'm using all of this later
userinput=newinput;
multiplelines=false; //this is a check to see if I should use the if statement later
for (var i = 0; i < length; i++) //loop threw each char in user input
{
teste=newinput.charAt(i); //gets the char at position i
if (teste.indexOf("<br />") != -1) //checks if …Run Code Online (Sandbox Code Playgroud) 如何逐行读取文本区域的内容或将文本拆分为不同的行以获取文本行的输入.
我使用的是AntDesign的TextArea,当我在其中输入2-3个段落,然后按回车键将其显示为一行时,它会在一个段落中显示所有内容。我想要我在文本区域中输入时所做的精确格式。怎么做?
我只是使用文本区域 -
<TextArea
rows={2}
style={{ width: "100%" }}
defaultValue={this.state.value}
onClick={this.handleValue}
/>
Run Code Online (Sandbox Code Playgroud)
并显示在右侧 -
<div>{this.state.value}</div>
Run Code Online (Sandbox Code Playgroud)
预期的
Hey, how are you doing today? I am fine. i hope your are fine
do give me a call when you are free.
contact - 1234567890
Run Code Online (Sandbox Code Playgroud)
我得到了什么结果
Hey, how are you doing today? I am fine. i hope your are fine do give me a call when you are free. contact - 1234567890
Run Code Online (Sandbox Code Playgroud)