我需要匹配所有这些开始标记:
<p>
<a href="foo">
Run Code Online (Sandbox Code Playgroud)
但不是这些:
<br />
<hr class="foo" />
Run Code Online (Sandbox Code Playgroud)
我想出了这个,并希望确保我做对了.我只抓住了a-z.
<([a-z]+) *[^/]*?>
Run Code Online (Sandbox Code Playgroud)
我相信它说:
/,然后我有这个权利吗?更重要的是,你怎么看?
而不是遍历每个字符以查看它是否是您想要的那个,然后将您的索引添加到列表中,如下所示:
var foundIndexes = new List<int>();
for (int i = 0; i < myStr.Length; i++)
{
if (myStr[i] == 'a')
foundIndexes.Add(i);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试复制 leetcode 所做的事情,作为我的 React 学习项目。以下是我当前的用户界面设置。
我使用 AceEditor 作为文本编辑器,现在我可以在更改时从编辑器中读取值。
containsDuplicate我想在单击按钮时执行该功能Run code。
我现在拥有的是一个字符串,codeValue以字符串格式表示用户的输入,以及testCase字符串格式的函数参数,
// the codeValue is the complete text in the Ace Editor are
const [codeValue, setCodeValue] = useState('');
// The testCase is [1,2,3,1] which reads from the TestCase section
const [testCase, setTextCaseValue] = useState('');
const submitHandler = (inputParams) => {
console.log(codeValue);
};
Run Code Online (Sandbox Code Playgroud)
我应该怎么做才能containsDuplicate使用 params运行该函数testCase?假设函数名称始终为containsDuplicate?
Eval() 会将字符串作为 JS 函数运行,但我需要的是,当字符串只是函数声明,并且有多个函数声明时,我需要从字符串中找到正确的函数,并使用给定的输入运行该函数。
假设输入字符串是
functionA() {
functionB();
}
functionB() {
}
Run Code Online (Sandbox Code Playgroud)
我需要读取该字符串并运行 …