我想找到字符串中的整个单词。但我不知道如何在kotlin中找到所有单词。我发现的词是[non alpha]cba[non alpha]。我的示例代码如下。
val testLink3 = """cba@cba cba"""
val word = "cba"
val matcher = "\\b[^a-zA-Z]*(?i)$word[^a-zA-Z]*\\b".toRegex()
val ret = matcher.find(testLink3)?.groupValues
Run Code Online (Sandbox Code Playgroud)
但我的源代码的输出是“cba”我的预期值是字符串数组,例如“{cba,cba,cba}”。如何在kotlin语言中找到这个值。
我想将子窗口定位到父窗口的中心。但是它在WPF中不起作用。
我定了StartupLocation = CenterOwner。但这是行不通的。
MainWindow.xaml.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Task.Run(async () =>
{
await Task.Delay(1000);
Dispatcher.Invoke(() => new TestWindow().ShowDialog());
});
}
}
Run Code Online (Sandbox Code Playgroud)
MainWindow.xaml
<Window x:Class="WpfApp29.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp29"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
TestWindow.xaml.cs
public partial class TestWindow : Window
{
public TestWindow()
{
InitializeComponent();
}
}
Run Code Online (Sandbox Code Playgroud)
TestWindow.xaml
<Window x:Class="WpfApp29.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp29"
WindowStartupLocation="CenterOwner"
mc:Ignorable="d"
Title="TestWindow" Height="300" Width="300">
<Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
我在中调用ShowDialog函数 …