问题是,我从提取的数据中收到的字符串包含许多HTML标签,例如< p >
,< h1 >
和< br >
我想删除这些。
请注意,我不使用JQuery
state = {
companyName: "Loading",
loading: true,
data: [] //THIS IS WHERE I STORE ALL THE DATA THAT I FETCH
}
data(props) {
return(
<div>
<Table celled>
<Table.Header>
<Table.Row>
<Table.HeaderCell>Index</Table.HeaderCell>
<Table.HeaderCell>Författning</Table.HeaderCell>
</Table.Row>
</Table.Header>
{props.map((lawList, index) => (
<Table.Body>
<Table.Row>
<Table.Cell>{index + 1}</Table.Cell>
/* The line below displays the data, but the data includes alot of html tags that i wish to have removed */
<Table.Cell>{lawList.lawDTO.name}</Table.Cell>
</Table.Row>
</Table.Body>
))}
</Table>
</div>
)
}
render() {
return(
<div>
<h3> {this.data(this.state.data)} </h3>
</div>
)}
}
答案 0 :(得分:1)
您可以使用正则表达式:
const test = '<br>asdasd</br><p>test</p>'.replace(/<.{1,2}>|<.{2,3}>/g, '');
console.log(test);
答案 1 :(得分:1)
您可以在读取数据后立即执行以下操作:
Option Explicit
Sub test()
Dim Lastrow As Long, i As Long
With ThisWorkbook.Sheets("Sheet1")
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 3 To Lastrow Step 2
.Range("A" & i & ":D" & i).Cut .Range("B" & i - 1 & ":E" & i - 1)
Next i
End With
End Sub
答案 2 :(得分:0)
可能要render the html吗?
render() {
return (
<div dangerouslySetInnerHTML={{ __html: this.state.data }}></div>
)
}