FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaRepository/Boris/src/laba16/FindPunctuations.java at master · karzhouAndrew/JavaRepository · GitHub
karzhouAndrew
/
JavaRepository
Public
Notifications
You must be signed in to change notification settings
Fork
16
Star
0
Code
Issues
0
Pull requests
96
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaRepository
/
Boris
/
src
/
laba16
/
FindPunctuations.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (29 loc) · 1.14 KB
Breadcrumbs
JavaRepository
/
Boris
/
src
/
laba16
/
FindPunctuations.java
Copy path
File metadata and controls
33 lines (29 loc) · 1.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package
laba16
;
import
java
.
util
.
regex
.
Matcher
;
import
java
.
util
.
regex
.
Pattern
;
//Дана строка. Найти и подсчитать все знаки препинания
public
class
FindPunctuations
{
private
final
static
Pattern
pattern
=
Pattern
.
compile
(
"
\\
p{Punct}"
);
public
static
int
getQuantityPunctual
(
String
str
) {
int
size
=
str
.
length
();
int
quantityPunctual
=
0
;
while
(
size
>
0
) {
char
letter
=
str
.
charAt
(
str
.
length
() -
size
);
if
(
letter
==
','
||
letter
==
'.'
||
letter
==
':'
||
letter
==
';'
||
letter
==
'!'
||
letter
==
'?'
||
letter
==
'('
||
letter
==
')'
||
letter
==
'{'
||
letter
==
'}'
||
letter
==
'['
||
letter
==
']'
||
letter
==
'/'
||
letter
==
'\''
) {
quantityPunctual
++;
}
size
--;
}
return
quantityPunctual
;
}
public
static
int
getQuantityPunctualOther
(
String
str
) {
Matcher
matcher
=
pattern
.
matcher
(
str
);
int
quantityPunctual
=
0
;
while
(
matcher
.
find
()) {
quantityPunctual
++;
}
return
quantityPunctual
;
}
}
Back
|
FazBrowse Home
|
New Git URL