任何人都可以帮助我,我怎样才能将整个文本分割成段与Java Selenium。每段文本(段落)都需要被提取。基本上,当文本行之间有换行符时,应该提取段落。 示例文本是:如何将文本拆分为段落
Description of rules
SAM/CAD are need to be discussed.
The required codes needed to be provided with accurate information.
Restricted:
- Smoking in the public place
- drink alcohol in the public places.
- Scream and make violations
SAM Setting:
not allowed
我的代码,这是不工作的,换句话说,它不分成几段:
String text=driver.findElement(By.xpath(".//*[@id='Content_tdMainContent']")).getText();
String[] eachSentence=text.split("^\\s*$");
分割空行'^ \ s * $'? [请参阅regex101](https://regex101.com/r/0XGVxb/1)。 – ClasG
它不起作用 –
@ S.Dase我认为整个问题是分割你可以从任何地方获得并与Java有关的'text'。它与Selenium有什么关系? – DebanjanB