Tbta va dt” kafedrasi mustaqil ish mavzu: Java Regex Topshirdi: 416-19-guruh talabasi Baxshullayev Baxrom Qabul qiladi: Oybek Jo’rayev Toshkent 2022 mundarija



Download 38,56 Kb.
bet3/3
Sana15.12.2022
Hajmi38,56 Kb.
#887375
1   2   3
Bog'liq
1- mustaqil ish t d

Example

Matches

[ab]

a yoki b lardan bittasi ni oladi a|b ga ekvivalent

[ab] [qw]



birinchi harf a yoki b ikkinchi harf esa q yoki w

[a-d]

a dan d gachaga ixtiyoriy bitta belgi

^[^a-zA-Z]

ixtiyoriy harf bilan boshlansin

[a-zA-Z0-9]$

ixtiyoriy bitta harf yoki ixtiyoriy raqam bilan tugasin

[0-9]%

ixtoyoriy bitta raqam va undan keyin % belgisi

Short Regex Belgilar





Regex

Description

.

Har qanday belgi

\d

har qanday raqam [0-9]

\D

Har qanday raqam bo'lmagan, qisqartmasi [^0-9]

\s

Har qanday boʻshliq belgisi [\t\n\x0B\f\r]

\S

Boʻsh joy boʻlmagan har qanday belgi, [^\s] ning qisqartmasi

\w

Har qanday so'z belgisi [a-zA-Z_0-9]

\W

Har qanday so'z bo’lmagan belgisi [^\w] ning qisqartmasi

\b

So'z chegarasi

\B

So'z chegara emas [^\b] ning qisqartmasi



public static void main(String args[]){
System.out.println(Pattern.matches("\\d", "abc")); false
System.out.println(Pattern.matches("\\d", "1")); true
System.out.println(Pattern.matches("\\d", "4443"));
System.out.println(Pattern.matches("\\D+", "abc")); true
System.out.println(Pattern.matches("\\D", "1"));
System.out.println(Pattern.matches("\\D+", "a323abc")); System.out.println(Pattern.matches("\\D", "m"))
System.out.println(Pattern.matches("\\D*", "mak")); true
}
Darsni takrorlab olish uchun

Example

Matches

^[The]

Any string that starts with The ^[The], The

of despair$

Any string that ends with of despair

^abc$

A string that starts and ends with abc—an exact match







ab*

A string that contains a, followed by zero or more bs—ac, abc, or abbc

ab+

A string that contains a, followed by one or more bs—abc or abbc, but not ac

ab?

A string that contains a, followed by zero or one bs—ac or abc, but not abc

a?b+$

A string that ends with one or more bs, with or without a preceding a; for example, ab, abb, b, or bb, but not aab or aabb







ab{2}

A string that contains a, followed by exactly 2 bs—abb

ab{2,}

A string that contains a, followed by at least 2 bs—abb, abbbb, etc.

ab{3,5}

A string that contains a, followed by three to five bs—abbb, abbbb, or abbbbb







hi|hello

A string that contains either hi or hello

(b|cd)ef

A string that contains either bef or cdef

(a|b)*c

A string that has a sequence of alternating as and bs, ending with c







a.[0-9]

A string that contains a, followed by any character and a digit

^.{3}$

Any string of exactly three characters







[ab]

A string that contains either a or b; equivalent to a|b

[a-d]

A string that contains a lowercase a, b, c, or d; equivalent to a|b|c|d or [abcd]

^[a-zA-Z]

A string that starts with any letter, regardless of case

[0-9]%

A string that contains any single digit followed by a percent sign

[a-zA-Z0-9]$

A string that ends with a comma followed by any character








Foydalanilgan adabiyotlar:



  1. https://www.w3schools.com/java/java_regex.asp

  2. https://coderlessons.com/?s=java+regex

  3. https://coderlessons.com/tutorials/java-tekhnologii/izuchite-java-regex/java-regex-interfeis-matchresult



Download 38,56 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish