সাধারণভাবে 7টি সাধারণ অমুদ্রণযোগ্য অক্ষর ব্যবহার করা হয় এবং প্রতিটি অক্ষরের নিজস্ব হেক্সাডেসিমেল উপস্থাপনা রয়েছে৷
| নাম | অক্ষর | হেক্সা-ডেসিমেল উপস্থাপনা |
|---|---|---|
| বেল | \a | 0x07 |
| এসকেপ | \e | 0x1B |
| ফর্ম ফিড | \f | 0x0C |
| লাইন ফিড | \n | 0x0A |
| ক্যারেজ রিটার্ন | \r | 0X0D |
| অনুভূমিক ট্যাব | \t | 0X09 |
| উল্লম্ব ট্যাব | \v | 0X0B |
উদাহরণ 1
জাভা প্রোগ্রাম অনুসরণ করে একটি ইনপুট টেক্সট গ্রহণ করে এবং এতে ট্যাব স্পেসের সংখ্যা গণনা করে −
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexExample1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter input text: ");
String input = sc.nextLine();
String regex = "\\t";
//Creating a pattern object
Pattern pattern = Pattern.compile(regex);
//Matching the compiled pattern in the String
Matcher matcher = pattern.matcher(input);
int count =0;
while (matcher.find()) {
count++;
}
System.out.println("Number of tab spaces in the given iput text: "+count);
}
} আউটপুট
sample text with tab spaces Number of tab spaces in the given input text: 3
উদাহরণ 2
আপনি মেলাতে অ-মুদ্রণযোগ্য অক্ষরগুলির সংশ্লিষ্ট হেক্সা-ডেসিমেল উপস্থাপনাগুলিও ব্যবহার করতে পারেন৷
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexExample1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter input text: ");
String input = sc.nextLine();
String regex = "\\x09";
//Creating a pattern object
Pattern pattern = Pattern.compile(regex);
//Matching the compiled pattern in the String
Matcher matcher = pattern.matcher(input);
int count =0;
while (matcher.find()) {
count++;
}
System.out.println("Number of tab spaces in the given iput text: "+count);
}
} আউটপুট
Enter input text: sample data with tab spaces Number of tab spaces in the given input text: 4