๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ282

[Java] ์ •๊ทœ ํ‘œํ˜„์‹ ์‚ฌ์šฉ๋ฐฉ๋ฒ• (Pattern, Matcher) ๐ŸŒผ ์ •๊ทœํ‘œํ˜„์‹ ์ž‘์„ฑ ๋ฐฉ๋ฒ• ๐ŸŒผ ์ •๊ทœ ํ‘œํ˜„์‹(Regular Expression) ์ด๋ž€ ํŠน์ •ํ•œ ๊ทœ์น™์„ ๊ฐ€์ง„ ๋ฌธ์ž์—ด์˜ ์ง‘ํ•ฉ์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด ์“ฐ์ด๋Š” ํ˜•์‹์–ธ์–ด ์ž…๋‹ˆ๋‹ค. ์ž๋ฐ” API java.util.regex ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ž‘์„ฑํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. โœจPattern ํด๋ž˜์Šค ์ •๊ทœ ํ‘œํ˜„์‹์— ๋Œ€์ƒ ๋ฌธ์ž์—ด์„ ๊ฒ€์ฆํ•˜๋Š” ๊ธฐ๋Šฅ์€ java.util.regex.Pattern ํด๋ž˜์Šค์˜ matches() ๋ฉ”์„œ๋“œ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ฒ€์ฆํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. matches() ๋ฉ”์„œ๋“œ์˜ ์ฒซ๋ฒˆ์งธ ๋งค๊ฐœ๊ฐ’์€ ์ •๊ทœํ‘œํ˜„์‹์ด๊ณ  ๋‘๋ฒˆ์งธ ๋งค๊ฐœ๊ฐ’์€ ๊ฒ€์ฆ ๋Œ€์ƒ ๋ฌธ์ž์—ด์ž…๋‹ˆ๋‹ค. ๊ฒ€์ฆ ํ›„ ๋Œ€์ƒ๋ฌธ์ž์—ด์ด ์ •๊ทœํ‘œํ˜„์‹๊ณผ ์ผ์น˜ํ•˜๋ฉด true, ๊ทธ๋ ‡์ง€ ์•Š๋‹ค๋ฉด false๊ฐ’์„ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค. import java.util.regex.Pattern; public class RegexExample {.. 2022. 4. 18.
[LeetCode] 3. Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the ans.. 2022. 4. 18.
[Java] ์ž๋ฐ” ์ •๊ทœํ‘œํ˜„์‹ ๋ชจ์Œ ๐ŸŒผ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ์ •๊ทœ ํ‘œํ˜„์‹ ๐ŸŒผ ์ •๊ทœ ํ‘œํ˜„์‹ ์„ค๋ช… ^[0-9]*$ ์ˆซ์ž ^[a-zA-Z]*$ ์˜๋ฌธ์ž ^[๊ฐ€-ํžฃ]*$ ํ•œ๊ธ€ \\w+@\\w+\\.\\w+(\\.\\w+)? E-mail ^[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-z]+$ E-mail ^\d{2,3}-\d{3,4}-\d{4}$ ์ „ํ™”๋ฒˆํ˜ธ ^01(?:0|1|[6-9])-(?:\d{3}|\d{4})-\d{4}$ ํœด๋Œ€์ „ํ™”๋ฒˆํ˜ธ \d{6}\-[1-4]\d{6} ์ฃผ๋ฏผ๋“ฑ๋ก๋ฒˆํ˜ธ ^\d{3}-\d{2}$ ์šฐํŽธ๋ฒˆํ˜ธ ๐ŸŒผ ๋งค์นญ๋  ๋ฌธ์ž๋ฅผ ์ง€์ •/์ œ์™ธํ•˜๋Š” ํ‘œํ˜„์‹ ๐ŸŒผ ์ •๊ทœ ํ‘œํ˜„์‹ ์„ค๋ช… [abc] a, b, c ์ค‘ ํ•˜๋‚˜์ด๋ฉด ์ผ์น˜ [^abc] a, b, c ๋ฅผ ์ œ์™ธํ•œ ๊ธ€์ž ์ด๋ฉด ์ผ์น˜ [a-zA-z] a ๋ถ€ํ„ฐ z๊นŒ์ง€์˜ ์†Œ๋ฌธ์ž ์•ŒํŒŒ๋ฒณ ์ด๊ฑฐ๋‚˜ A ๋ถ€ํ„ฐ Z๊นŒ์ง€์˜ ๋Œ€๋ฌธ.. 2022. 4. 18.
[SQLD] 30ํšŒ ๊ธฐ์ถœ ๋ฌธ์ œ ( 50๋ฌธ์ œ / ์ •๋‹ต,ํ•ด์„คํฌํ•จ ) ๐Ÿ“–SQLD. ์ œ 30 ํšŒ ๊ธฐ์ถœ ๋ฌธ์ œ ๋ฌธ์ œ 1. ์•„๋ž˜ ๋‚ด์šฉ์˜ ํŠน์ง•์€ ๋ฌด์—‡์„ ์„ค๋ช…ํ•˜๊ณ  ์žˆ๋Š”์ง€ ๊ณ ๋ฅด์‹œ์˜ค. ์ •๋‹ตํ™•์ธ๐ŸŒผ [ ์„ค๋ช… ] ์—”ํ„ฐํ‹ฐ ๋‚ด์—์„œ ์†์„ฑ์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ ํƒ€์ž…๊ณผ ํฌ๊ธฐ ๊ทธ๋ฆฌ๊ณ  ์ œ์•ฝ์‚ฌํ•ญ์„ ์ง€์ •ํ•˜๋Š” ๊ฒƒ 1) ์ œ์•ฝ์กฐ๊ฑด 2) ๋„๋ฉ”์ธ 3) ์ •๊ทœํ™” 4) ์‹๋ณ„์ž ๋ฌธ์ œ 2. ์•„๋ž˜์˜ ๋ฐ˜์ •๊ทœํ™”์— ๋Œ€ํ•œ ์„ค๋ช… ์ค‘ ๋ถ€์ ์ ˆํ•œ ๊ฒƒ์€? ์ •๋‹ตํ™•์ธ๐ŸŒผ 1) ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•  ๋•Œ ๋””์Šคํฌ I/O ๋Ÿ‰์ด ๋งŽ์•„์„œ ์„ฑ๋Šฅ์ด ์ €ํ•˜๋˜๊ฑฐ๋‚˜ ๊ฒฝ๋กœ๊ฐ€ ๋„ˆ๋ฌด ๋ฉ€์–ด ์กฐ์ธ์œผ๋กœ ์ธํ•œ ์„ฑ๋Šฅ์ €ํ•˜๊ฐ€ ์˜ˆ์ƒ๋  ๋•Œ ์ˆ˜ํ–‰ํ•œ๋‹ค. 2) ์ปฌ๋Ÿผ์„ ๊ณ„์‚ฐํ•˜์—ฌ ์ฝ์„ ๋•Œ ์„ฑ๋Šฅ์ด ์ €ํ•˜๋  ๊ฒƒ์ด ์˜ˆ์ƒ๋˜๋Š” ๊ฒฝ์šฐ ์ˆ˜ํ–‰ํ•œ๋‹ค. 3) ๋ฐ˜์ •๊ทœํ™”๋ฅผ ์ ์šฉํ•  ๋•Œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ฐ์ดํ„ฐ ๋ฌด๊ฒฐ์„ฑ์ด ๊นจ์งˆ ๊ฐ€๋Šฅ์„ฑ์ด ๋งŽ์ด ์žˆ์œผ๋ฏ€๋กœ ๋ฐ˜๋“œ์‹œ ๋ฐ์ดํ„ฐ ๋ฌด๊ฒฐ์„ฑ์„ ๋ณด์žฅํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ๊ณ ๋ คํ•ด์•ผํ•œ๋‹ค. 4) ๋ฐ˜์ •๊ทœํ™” ์ „์— ํ…Œ์ด๋ธ” ์ถ”๊ฐ€(ํ†ต๊ณ„.. 2022. 4. 17.
[LeetCode] 58. Length of Last Word 58. Length of Last Word Given a string s consisting of some words separated by some number of spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only. Example 1: Input: s = "Hello World" Output: 5 Explanation: The last word is "World" with length 5. Example 2: Input: s = " fly me to the moon " Output: 4 Explanation: The last.. 2022. 4. 17.
[LeetCode] 9. Palindrome Number ๐Ÿ“–๋ฌธ์ œ. ์ˆซ์ž๊ฐ€ ์ž…๋ ฅ๋˜๋ฉด ํ•ด๋‹น ์ˆซ์ž๊ฐ€ ํŒฐ๋ฆฐ๋“œ๋กฌ์ด๋ฉด true, ์•„๋‹ˆ๋ฉด false ๋ฅผ ์ถœ๋ ฅํ•˜์„ธ์š”. Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanatio.. 2022. 4. 17.
300x250

์ฝ”๋“œ