Skip to content

Commit 007e6b3

Browse files
authored
Merge pull request #23 from TidierOrg/str_count
2 parents 3c9fee9 + 7d5a6f7 commit 007e6b3

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/docstrings.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
const docstring_str_detect = """
2-
str_detect(string::String, pattern::Union{String, Regex})
1+
const docstring_str_detect =
2+
"""
3+
str_detect(string::String, pattern::Union{String, Regex}; overlap::Bool=false)
34
45
Determine if a string contains a certain pattern.
56
6-
# Arguments
7-
- `string`: The string to check.
8-
pattern: A string or a regular expression to find within the string.
9-
The pattern can include special logic:
7+
# Arguments
8+
- `string`: The string to check.
9+
- `pattern`: A string or a regular expression to find within the string.
10+
- `overlap`: Whether the pattern can overlap (default false)
11+
12+
The pattern can include special logic:
1013
1114
Use | to represent "or" (e.g., "red|blue" matches any string that contains "red" or "blue").
1215
Use & to represent "and" (e.g., "red&blue" matches any string that contains both "red" and "blue").

src/matching.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
$docstring_str_count
33
"""
4-
function str_count(column, pattern::Union{String,Regex})
4+
function str_count(column, pattern::Union{String,Regex}; overlap::Bool=false)
55
if ismissing(column)
66
return (column)
77
end
@@ -11,7 +11,7 @@ function str_count(column, pattern::Union{String,Regex})
1111
end
1212

1313
# Count the number of matches for the regular expression
14-
return length(collect(eachmatch(pattern, column)))
14+
return length(collect(eachmatch(pattern, column, overlap=overlap)))
1515
end
1616

1717
"""

0 commit comments

Comments
 (0)