Skip to content

Conversation

@mdgrs-mei
Copy link
Owner

This PR adds NameSearchablePattern and DescriptionSearchablePattern properties to SelectorEntry. If specified, Only characters that are matched by the regex pattern will be searchable.

Example1: The second word split by space is searchable

$pattern = [Regex]::new('(?<=^\S*\s).*?(?=\s|$)')
'aaa bbb aaa', 'bbb aaa bbb' | ForEach-Object {
    $entry = [PowerShellRun.SelectorEntry]::new()
    $entry.Name = $_
    $entry.NameSearchablePattern = $pattern
    $entry
} | Invoke-PSRunSelectorCustom

image

Example2: All words inside [] are searchable

$pattern = [Regex]::new('(?<=\[).*?(?=\])')
'aaa [bbb] [ccc]', '[aaa] bbb ccc' | ForEach-Object {
    $entry = [PowerShellRun.SelectorEntry]::new()
    $entry.Name = $_
    $entry.NameSearchablePattern = $pattern
    $entry
} | Invoke-PSRunSelectorCustom

image

Example3: Method or Property names are searchable

$pattern = [Regex]::new('(?<=^\S*\s).*?(?=\s|\(|{|$)')
$members = [Regex] | Get-Member
$members | ForEach-Object {
    $entry = [PowerShellRun.SelectorEntry]::new()
    $entry.Name = $_.Definition
    $entry.NameSearchablePattern = $pattern
    $entry
} | Invoke-PSRunSelectorCustom

image

@mdgrs-mei mdgrs-mei merged commit 359ae24 into main May 14, 2024
@mdgrs-mei mdgrs-mei deleted the add-searchable-area-pattern branch May 14, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants