We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Regex
- Applications
- Valid PAN format
- Discussions
Valid PAN format
Valid PAN format
+ 0 comments import re [print("YES" if re.match(r"\A[A-Z]{5}\d{4}[A-Z]\Z", input()) is not None else "NO") for _ in range(int(input()))]
+ 0 comments Concise solution in python 3
import re for _ in range(int(input())): print("YES" if bool(re.match(r'^[A-Z]{5}\d{4}[A-Z]$', input())) else "NO")
+ 0 comments import re N = int(input()) for _ in range(N): S = input() if re.search(r"^[A-Z]{5}\d{4}[A-Z]$",S) : print("YES") else : print("NO")
+ 0 comments python
import re pattern = re.compile(r'^[A-Z]{5}\d{4}[A-Z]$') for _ in range(int(input())): if pattern.match(input()): print("YES") else: print("NO")
+ 0 comments Swift Solution
import Foundation // Enter your code here func findString(for pattern: String, inText text: String) -> String? { let regex = try? NSRegularExpression(pattern: pattern) if let firstMatch = regex?.firstMatch(in: text, range: NSRange(text.startIndex... , in: text)) { return String(text[Range(firstMatch.range, in: text)!]) } return nil } let panPattern = #"^[A-Z]{5}\d{4}[A-Z]$"# let times = Int(readLine()!)! (1...times).forEach { _ in let text = readLine()! if let _ = findString(for: panPattern, inText: text) { print("YES") } else { print("NO") } }
Load more conversations
Sort 71 Discussions, By:
Please Login in order to post a comment