স্ট্রিং ফাংশন
| নাম | বর্ণনা |
BYTE_LENGTH | একটি STRING বা BYTES ভ্যালুতে থাকা BYTES সংখ্যা ফেরত দেয়। |
CHAR_LENGTH | একটি STRING ভ্যালুতে থাকা ইউনিকোড ক্যারেক্টারের সংখ্যা ফেরত দেয়। |
STARTS_WITH | যদি কোনো STRING প্রদত্ত প্রিফিক্স দিয়ে শুরু হয়, তাহলে TRUE রিটার্ন করে। |
ENDS_WITH | যদি কোনো STRING প্রদত্ত পোস্টফিক্স দিয়ে শেষ হয়, তাহলে TRUE রিটার্ন করে। |
LIKE | যদি কোনো STRING প্যাটার্নের সাথে মিলে যায়, তাহলে TRUE রিটার্ন করে। |
REGEX_CONTAINS | কোনো মান রেগুলার এক্সপ্রেশনের সাথে আংশিক বা সম্পূর্ণভাবে মিলে গেলে TRUE রিটার্ন করে। |
REGEX_MATCH | কোনো মানের কোনো অংশ রেগুলার এক্সপ্রেশনের সাথে মিলে গেলে TRUE রিটার্ন করে। |
STRING_CONCAT | একাধিক STRING সংযুক্ত করে একটি STRING তৈরি করে |
STRING_CONTAINS | যদি কোনো মানে একটি STRING থাকে তবে TRUE রিটার্ন করে। |
STRING_INDEX_OF | একটি STRING বা BYTES মানের প্রথম উপস্থিতির ০-ভিত্তিক সূচক ফেরত দেয়। |
TO_UPPER | STRING বা BYTES মানকে বড় হাতের অক্ষরে রূপান্তর করে। |
TO_LOWER | STRING বা BYTES মানকে ছোট হাতের অক্ষরে রূপান্তর করে। |
SUBSTRING | একটি STRING বা BYTES মানের একটি সাবস্ট্রিং গ্রহণ করে। |
STRING_REVERSE | একটি STRING বা BYTES মানকে বিপরীত করে। |
STRING_REPEAT | একটি STRING বা BYTES মানকে নির্দিষ্ট সংখ্যক বার পুনরাবৃত্তি করে। |
STRING_REPLACE_ALL | STRING বা BYTES মানের সমস্ত উপস্থিতি প্রতিস্থাপন করে। |
STRING_REPLACE_ONE | STRING বা BYTES মানের প্রথম উপস্থিতি প্রতিস্থাপন করে। |
TRIM | একটি STRING বা BYTES ভ্যালু থেকে শুরুতে ও শেষে থাকা অক্ষরগুলো ছেঁটে ফেলে। |
LTRIM | STRING বা BYTES ভ্যালু থেকে শুরুর দিকের অক্ষরগুলো ছেঁটে ফেলে। |
RTRIM | STRING বা BYTES মানের শেষের অক্ষরগুলো ছেঁটে ফেলে। |
SPLIT | একটি STRING বা BYTES মানকে একটি অ্যারেতে বিভক্ত করে। |
বাইট_দৈর্ঘ্য
সিনট্যাক্স:
byte_length[T <: STRING | BYTES](value: T) -> INT64
বর্ণনা:
একটি STRING বা BYTES মানের মধ্যে থাকা BYTES সংখ্যা ফেরত দেয়।
উদাহরণ:
| মূল্য | byte_length(value) |
|---|---|
| "এবিসি" | ৩ |
| "xyzabc" | ৬ |
| b"abc" | ৩ |
নোড.জেএস
const result = await db.pipeline() .collection("books") .select( field("title").byteLength().as("titleByteLength") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("title").byteLength().as("titleByteLength") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").byteLength().as("titleByteLength") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").byteLength().alias("titleByteLength") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").byteLength().alias("titleByteLength") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").byte_length().as_("titleByteLength")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(byteLength(field("title")).as("titleByteLength")) .execute() .get();
অক্ষরের দৈর্ঘ্য
সিনট্যাক্স:
char_length(value: STRING) -> INT64
বর্ণনা:
STRING ভ্যালুতে থাকা ইউনিকোড কোড পয়েন্টের সংখ্যা ফেরত দেয়।
উদাহরণ:
| মূল্য | char_length(value) |
|---|---|
| "এবিসি" | ৩ |
| "হ্যালো" | ৫ |
| "বিশ্ব" | ৫ |
নোড.জেএস
const result = await db.pipeline() .collection("books") .select( field("title").charLength().as("titleCharLength") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("title").charLength().as("titleCharLength") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").charLength().as("titleCharLength") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").charLength().alias("titleCharLength") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").charLength().alias("titleCharLength") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("title").char_length().as_("titleCharLength")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(charLength(field("title")).as("titleCharLength")) .execute() .get();
STARTS_WITH
সিনট্যাক্স:
starts_with(value: STRING, prefix: STRING) -> BOOLEAN
বর্ণনা:
যদি value prefix দিয়ে শুরু হয়, তাহলে TRUE রিটার্ন করে।
উদাহরণ:
| মূল্য | উপসর্গ | starts_with(value, prefix) |
|---|---|---|
| "এবিসি" | "ক" | সত্য |
| "এবিসি" | "খ" | মিথ্যা |
| "এবিসি" | "" | সত্য |
নোড.জেএস
const result = await db.pipeline() .collection("books") .select( field("title").startsWith("The") .as("needsSpecialAlphabeticalSort") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("title").startsWith("The") .as("needsSpecialAlphabeticalSort") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").startsWith("The") .as("needsSpecialAlphabeticalSort") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").startsWith("The") .alias("needsSpecialAlphabeticalSort") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").startsWith("The") .alias("needsSpecialAlphabeticalSort") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("title").starts_with("The").as_("needsSpecialAlphabeticalSort") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(startsWith(field("title"), "The").as("needsSpecialAlphabeticalSort")) .execute() .get();
ENDS_WITH
সিনট্যাক্স:
ends_with(value: STRING, postfix: STRING) -> BOOLEAN
বর্ণনা:
যদি value শেষে postfix থাকে, তাহলে TRUE রিটার্ন করে।
উদাহরণ:
| মূল্য | পোস্টফিক্স | ends_with(value, postfix) |
|---|---|---|
| "এবিসি" | "গ" | সত্য |
| "এবিসি" | "খ" | মিথ্যা |
| "এবিসি" | "" | সত্য |
নোড.জেএস
const result = await db.pipeline() .collection("inventory/devices/laptops") .select( field("name").endsWith("16 inch") .as("16InLaptops") ) .execute();
সুইফট
let result = try await db.pipeline() .collection("inventory/devices/laptops") .select([ Field("name").endsWith("16 inch") .as("16InLaptops") ]) .execute()
Kotlin
val result = db.pipeline() .collection("inventory/devices/laptops") .select( field("name").endsWith("16 inch") .alias("16InLaptops") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("inventory/devices/laptops") .select( field("name").endsWith("16 inch") .alias("16InLaptops") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("inventory/devices/laptops") .select(Field.of("name").ends_with("16 inch").as_("16InLaptops")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("inventory/devices/laptops") .select(endsWith(field("name"), "16 inch").as("16InLaptops")) .execute() .get();
লাইক
সিনট্যাক্স:
like(value: STRING, pattern: STRING) -> BOOLEAN
বর্ণনা:
value pattern সাথে মিলে গেলে TRUE রিটার্ন করে।
উদাহরণ:
| মূল্য | প্যাটার্ন | like(value, pattern) |
|---|---|---|
| "ফায়ারস্টোর" | "ফায়ার%" | সত্য |
| "ফায়ারস্টোর" | "%স্টোর" | সত্য |
| "ডেটাস্টোর" | "ডেটা_স্টোর" | সত্য |
| ১০০% | ১০০% | সত্য |
নোড.জেএস
const result = await db.pipeline() .collection("books") .select( field("genre").like("%Fiction") .as("anyFiction") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("genre").like("%Fiction") .as("anyFiction") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("genre").like("%Fiction") .as("anyFiction") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("genre").like("%Fiction") .alias("anyFiction") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("genre").like("%Fiction") .alias("anyFiction") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("genre").like("%Fiction").as_("anyFiction")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(like(field("genre"), "%Fiction").as("anyFiction")) .execute() .get();
REGEX_CONTAINS
সিনট্যাক্স:
regex_contains(value: STRING, pattern: STRING) -> BOOLEAN
বর্ণনা:
যদি value কোনো অংশ pattern সাথে মিলে যায়, তাহলে TRUE রিটার্ন করে। যদি pattern একটি বৈধ রেগুলার এক্সপ্রেশন না হয়, তাহলে এই ফাংশনটি একটি error রিটার্ন করে।
রেগুলার এক্সপ্রেশনগুলো re2 লাইব্রেরির সিনট্যাক্স অনুসরণ করে।
উদাহরণ:
| মূল্য | প্যাটার্ন | regex_contains(value, pattern) |
|---|---|---|
| "ফায়ারস্টোর" | "আগুন" | সত্য |
| "ফায়ারস্টোর" | "স্টোর$" | সত্য |
| "ফায়ারস্টোর" | "ডেটা" | মিথ্যা |
নোড.জেএস
const result = await db.pipeline() .collection("documents") .select( field("title").regexContains("Firestore (Enterprise|Standard)") .as("isFirestoreRelated") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("title").regexContains("Firestore (Enterprise|Standard)") .as("isFirestoreRelated") ) );
সুইফট
let result = try await db.pipeline() .collection("documents") .select([ Field("title").regexContains("Firestore (Enterprise|Standard)") .as("isFirestoreRelated") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("title").regexContains("Firestore (Enterprise|Standard)") .alias("isFirestoreRelated") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("title").regexContains("Firestore (Enterprise|Standard)") .alias("isFirestoreRelated") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("title") .regex_contains("Firestore (Enterprise|Standard)") .as_("isFirestoreRelated") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select( regexContains(field("title"), "Firestore (Enterprise|Standard)") .as("isFirestoreRelated")) .execute() .get();
REGEX_MATCH
সিনট্যাক্স:
regex_match(value: STRING, pattern: STRING) -> BOOLEAN
বর্ণনা:
যদি value pattern সাথে সম্পূর্ণরূপে মিলে যায় তবে TRUE রিটার্ন করে। যদি pattern একটি বৈধ রেগুলার এক্সপ্রেশন না হয়, তবে এই ফাংশনটি একটি error রিটার্ন করে।
রেগুলার এক্সপ্রেশনগুলো re2 লাইব্রেরির সিনট্যাক্স অনুসরণ করে।
উদাহরণ:
| মূল্য | প্যাটার্ন | regex_match(value, pattern) |
|---|---|---|
| "ফায়ারস্টোর" | "এফ.*স্টোর" | সত্য |
| "ফায়ারস্টোর" | "আগুন" | মিথ্যা |
| "ফায়ারস্টোর" | "^F.*e$" | সত্য |
নোড.জেএস
const result = await db.pipeline() .collection("documents") .select( field("title").regexMatch("Firestore (Enterprise|Standard)") .as("isFirestoreExactly") ) .execute();
Web
const result = await execute(db.pipeline() .collection("documents") .select( field("title").regexMatch("Firestore (Enterprise|Standard)") .as("isFirestoreExactly") ) );
সুইফট
let result = try await db.pipeline() .collection("documents") .select([ Field("title").regexMatch("Firestore (Enterprise|Standard)") .as("isFirestoreExactly") ]) .execute()
Kotlin
val result = db.pipeline() .collection("documents") .select( field("title").regexMatch("Firestore (Enterprise|Standard)") .alias("isFirestoreExactly") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("documents") .select( field("title").regexMatch("Firestore (Enterprise|Standard)") .alias("isFirestoreExactly") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("documents") .select( Field.of("title") .regex_match("Firestore (Enterprise|Standard)") .as_("isFirestoreExactly") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("documents") .select( regexMatch(field("title"), "Firestore (Enterprise|Standard)") .as("isFirestoreExactly")) .execute() .get();
স্ট্রিং_কনক্যাট
সিনট্যাক্স:
string_concat(values: STRING...) -> STRING
বর্ণনা:
দুই বা ততোধিক STRING মানকে সংযুক্ত করে একটি একক ফলাফল তৈরি করে।
উদাহরণ:
| যুক্তি | string_concat(values...) |
|---|---|
() | ত্রুটি |
("a") | "ক" |
("abc", "def") | "abcdef" |
("a", "", "c") | "এসি" |
নোড.জেএস
const result = await db.pipeline() .collection("books") .select( field("title").stringConcat(" by ", field("author")) .as("fullyQualifiedTitle") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("title").stringConcat(" by ", field("author")) .as("fullyQualifiedTitle") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("title").concat([" by ", Field("author")]) .as("fullyQualifiedTitle") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("title").concat(" by ", field("author")) .alias("fullyQualifiedTitle") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("title").concat(" by ", field("author")) .alias("fullyQualifiedTitle") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select( Field.of("title") .concat(" by ", Field.of("author")) .as_("fullyQualifiedTitle") ) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(stringConcat(field("title"), " by ", field("author")).as("fullyQualifiedTitle")) .execute() .get();
স্ট্রিং_ধারণ করে
সিনট্যাক্স:
string_contains(value: STRING, substring: STRING) -> BOOLEAN
বর্ণনা:
value আক্ষরিক স্ট্রিং substring আছে কিনা তা যাচাই করে।
উদাহরণ:
| মূল্য | সাবস্ট্রিং | string_contains(value, substring) |
|---|---|---|
| "এবিসি" | "খ" | সত্য |
| "এবিসি" | "d" | মিথ্যা |
| "এবিসি" | "" | সত্য |
| "এসি" | "." | সত্য |
| "☃☃☃" | "☃" | সত্য |
নোড.জেএস
const result = await db.pipeline() .collection("articles") .select( field("body").stringContains("Firestore") .as("isFirestoreRelated") ) .execute();
Web
const result = await execute(db.pipeline() .collection("articles") .select( field("body").stringContains("Firestore") .as("isFirestoreRelated") ) );
সুইফট
let result = try await db.pipeline() .collection("articles") .select([ Field("body").stringContains("Firestore") .as("isFirestoreRelated") ]) .execute()
Kotlin
val result = db.pipeline() .collection("articles") .select( field("body").stringContains("Firestore") .alias("isFirestoreRelated") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("articles") .select( field("body").stringContains("Firestore") .alias("isFirestoreRelated") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("articles") .select(Field.of("body").string_contains("Firestore").as_("isFirestoreRelated")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("articles") .select(stringContains(field("body"), "Firestore").as("isFirestoreRelated")) .execute() .get();
স্ট্রিং_সূচক_অফ
সিনট্যাক্স:
string_index_of[T <: STRING | BYTES](value: T, search: T) -> INT64
বর্ণনা:
value তে search এর প্রথম উপস্থিতির ০-ভিত্তিক সূচকটি ফেরত দেয়।
-
searchখুঁজে না পেলে-1ফেরত দেয়। - যদি
valueএকটিSTRINGহয়, তাহলে ফলাফলটি ইউনিকোড কোড পয়েন্টে পরিমাপ করা হয়। আর যদি এটি একটিBYTESহয়, তাহলে তা বাইটে পরিমাপ করা হয়। - যদি
searchভ্যালুটি একটি খালিSTRINGবাBYTESহয়, তাহলে ফলাফল হবে0।
উদাহরণ:
| মূল্য | অনুসন্ধান | string_index_of(value, search) |
|---|---|---|
| "হ্যালো ওয়ার্ল্ড" | "ও" | ৪ |
| "হ্যালো ওয়ার্ল্ড" | "l" | ২ |
| "হ্যালো ওয়ার্ল্ড" | "z" | -১ |
| 'কলা' | "না" | ২ |
| "এবিসি" | "" | ০ |
| b"abc" | খ"খ" | ১ |
| "é" | "é" | ০ |
| b"é" | b"é" | ০ |
TO_UPPER
সিনট্যাক্স:
to_upper[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
STRING বা BYTES মানকে বড় হাতের অক্ষরে রূপান্তর করে।
যদি কোনো বাইট বা ক্যারেক্টার UTF-8 এর ছোট হাতের বর্ণমালার সাথে সঙ্গতিপূর্ণ না হয়, তবে তা অপরিবর্তিতভাবে প্রেরণ করা হয়।
উদাহরণ:
| মূল্য | to_upper(value) |
|---|---|
| "এবিসি" | "এবিসি" |
| "AbC" | "এবিসি" |
| b"abc" | b"ABC" |
| b"a1c" | b"A1C" |
নোড.জেএস
const result = await db.pipeline() .collection("authors") .select( field("name").toUpper() .as("uppercaseName") ) .execute();
Web
const result = await execute(db.pipeline() .collection("authors") .select( field("name").toUpper() .as("uppercaseName") ) );
সুইফট
let result = try await db.pipeline() .collection("authors") .select([ Field("name").toUpper() .as("uppercaseName") ]) .execute()
Kotlin
val result = db.pipeline() .collection("authors") .select( field("name").toUpper() .alias("uppercaseName") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("authors") .select( field("name").toUpper() .alias("uppercaseName") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("authors") .select(Field.of("name").to_upper().as_("uppercaseName")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("authors") .select(toUpper(field("name")).as("uppercaseName")) .execute() .get();
TO_LOWER
সিনট্যাক্স:
to_lower[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
STRING বা BYTES মানকে ছোট হাতের অক্ষরে রূপান্তর করে।
যদি কোনো বাইট বা ক্যারেক্টার UTF-8 এর বড় হাতের বর্ণমালার সাথে সঙ্গতিপূর্ণ না হয়, তবে তা অপরিবর্তিতভাবে প্রেরণ করা হয়।
উদাহরণ:
| মূল্য | to_lower(value) |
|---|---|
| "এবিসি" | "এবিসি" |
| "AbC" | "এবিসি" |
| "এ১সি" | "a1c" |
| b"ABC" | b"abc" |
নোড.জেএস
const result = await db.pipeline() .collection("authors") .select( field("genre").toLower().equal("fantasy") .as("isFantasy") ) .execute();
Web
const result = await execute(db.pipeline() .collection("authors") .select( field("genre").toLower().equal("fantasy") .as("isFantasy") ) );
সুইফট
let result = try await db.pipeline() .collection("authors") .select([ Field("genre").toLower().equal("fantasy") .as("isFantasy") ]) .execute()
Kotlin
val result = db.pipeline() .collection("authors") .select( field("genre").toLower().equal("fantasy") .alias("isFantasy") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("authors") .select( field("genre").toLower().equal("fantasy") .alias("isFantasy") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("authors") .select(Field.of("genre").to_lower().equal("fantasy").as_("isFantasy")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("authors") .select(equal(toLower(field("genre")), "fantasy").as("isFantasy")) .execute() .get();
সাবস্ট্রিং
সিনট্যাক্স:
substring[T <: STRING | BYTES](input: T, position: INT64) -> T
substring[T <: STRING | BYTES](input: T, position: INT64, length: INT64) -> T
বর্ণনা:
input একটি সাবস্ট্রিং ফেরত দেয় যা position (শূন্য-ভিত্তিক সূচক) থেকে শুরু হয়ে length পর্যন্ত এন্ট্রি অন্তর্ভুক্ত করে। যদি কোনো length প্রদান করা না হয়, তাহলে position থেকে input শেষ পর্যন্ত সাবস্ট্রিংটি ফেরত দেয়।
inputযদি একটিSTRINGভ্যালু হয়, তবেpositionএবংlengthইউনিকোড কোড পয়েন্টে পরিমাপ করা হয়। আর যদি এটি একটিBYTESভ্যালু হয়, তবে তা বাইটে পরিমাপ করা হয়।যদি
positioninputদৈর্ঘ্যের চেয়ে বড় হয়, তাহলে একটি খালি সাবস্ট্রিং ফেরত দেওয়া হয়। যদিpositionওlengthযোগফলinputদৈর্ঘ্যের চেয়ে বড় হয়, তাহলে সাবস্ট্রিংটিinputশেষ পর্যন্ত ছেঁটে ফেলা হয়।positionঋণাত্মক হলে, ইনপুটের শেষ থেকে অবস্থানটি নেওয়া হয়। যদি ঋণাত্মকpositionইনপুটের আকারের চেয়ে বড় হয়, তবে অবস্থানটি শূন্যে সেট করা হয়।lengthঅবশ্যই অঋণাত্মক হতে হবে।
উদাহরণ:
যখন length প্রদান করা হয় না:
| ইনপুট | অবস্থান | substring(input, position) |
|---|---|---|
| "এবিসি" | ০ | "এবিসি" |
| "এবিসি" | ১ | "বিসি" |
| "এবিসি" | ৩ | "" |
| "এবিসি" | -১ | "গ" |
| b"abc" | ১ | b"bc" |
যখন length প্রদান করা হয়:
| ইনপুট | অবস্থান | দৈর্ঘ্য | substring(input, position, length) |
|---|---|---|---|
| "এবিসি" | ০ | ১ | "ক" |
| "এবিসি" | ১ | ২ | "বিসি" |
| "এবিসি" | -১ | ১ | "গ" |
| b"abc" | ০ | ১ | খ"ক" |
নোড.জেএস
const result = await db.pipeline() .collection("books") .where(field("title").startsWith("The ")) .select( field("title").substring(4) .as("titleWithoutLeadingThe") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .where(field("title").startsWith("The ")) .select( field("title").substring(4) .as("titleWithoutLeadingThe") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .where(Field("title").startsWith("The ")) .select([ Field("title").substring(position: 4) .as("titleWithoutLeadingThe") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .where(field("title").startsWith("The ")) .select( field("title") .substring(constant(4), field("title").charLength().subtract(4)) .alias("titleWithoutLeadingThe") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .where(field("title").startsWith("The ")) .select( field("title").substring( constant(4), field("title").charLength().subtract(4)) .alias("titleWithoutLeadingThe") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .where(Field.of("title").starts_with("The ")) .select(Field.of("title").substring(4).as_("titleWithoutLeadingThe")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .where(startsWith(field("title"), "The ")) .select( substring(field("title"), constant(4), field("title").charLength()) .as("titleWithoutLeadingThe")) .execute() .get();
স্ট্রিং_রিভার্স
সিনট্যাক্স:
string_reverse[T <: STRING | BYTES](input: T) -> T
বর্ণনা:
প্রদত্ত ইনপুট বিপরীত ক্রমে ফেরত দেয়।
ইনপুটটি STRING হলে ক্যারেক্টারগুলোকে ইউনিকোড কোড পয়েন্ট দ্বারা এবং বাইট BYTES ভ্যালু হলে বাইট দ্বারা চিহ্নিত করা হয়।
উদাহরণ:
| ইনপুট | string_reverse(input) |
|---|---|
| "এবিসি" | "cba" |
| "a🌹b" | "b🌹a" |
| "হ্যালো" | "ওলেহ" |
| b"abc" | b"cba" |
নোড.জেএস
const result = await db.pipeline() .collection("books") .select( field("name").reverse().as("reversedName") ) .execute();
Web
const result = await execute(db.pipeline() .collection("books") .select( field("name").reverse().as("reversedName") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("name").reverse().as("reversedName") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("name").reverse().alias("reversedName") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("name").reverse().alias("reversedName") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("name").string_reverse().as_("reversedName")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(reverse(field("name")).as("reversedName")) .execute() .get();
স্ট্রিং_রিপিট
সিনট্যাক্স:
string_repeat[T <: STRING | BYTES](input: T, repetitions: INT64) -> T
বর্ণনা:
input repetitions সংখ্যা ফেরত দেয়।
-
repetitionsঅবশ্যই একটি অঋণাত্মক পূর্ণসংখ্যা হতে হবে। -
repetitionsসংখ্যা0হলে,inputমতোই একটি খালি মান ফেরত দেওয়া হয়। - ফলাফল সর্বোচ্চ অনুমোদিত আকার (১ এমবি) অতিক্রম করলে একটি ত্রুটি দেখানো হয়।
উদাহরণ:
| ইনপুট | পুনরাবৃত্তি | string_repeat(input, repetitions) |
|---|---|---|
| "ফু" | ৩ | "ফুফুফু" |
| "ফু" | ০ | "" |
| "ক" | ৩ | "আআআ" |
| b"ab" | ২ | b"abab" |
| "é🦆" | ২ | "é🦆é🦆" |
সব স্ট্রিং প্রতিস্থাপন করুন
সিনট্যাক্স:
string_replace_all[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T
বর্ণনা:
input find এর সকল অ-ওভারল্যাপিং উপস্থিতিকে ' replacement দ্বারা প্রতিস্থাপন করে।
- মিলগুলো কেস-সেনসিটিভ।
-
findখালি থাকলে, কোনো প্রতিস্থাপন করা হয় না।
উদাহরণ:
| ইনপুট | খুঁজুন | প্রতিস্থাপন | string_replace_all(input, find, replacement) |
|---|---|---|---|
| "ফুবারফু" | "ফু" | "বাজ" | "বাজবারবাজ" |
| "আবাবাব" | "আবা" | "গ" | "cbab" |
| "ফুবার" | "ও" | "" | "fbar" |
| "é🦆🌎🦆" | "🦆" | "ক" | "éa🌎a" |
| b"abc" | খ"খ" | খ"দ" | b"adc" |
স্ট্রিং_রিপ্লেস_ওয়ান
সিনট্যাক্স:
string_replace_one[T <: STRING | BYTES](input: T, find: T, replacement: T) -> T
বর্ণনা:
input find এর প্রথম উপস্থিতিকে replacement দিয়ে প্রতিস্থাপন করে।
- মিলগুলো কেস-সেনসিটিভ।
-
findখালি থাকলে, কোনো প্রতিস্থাপন করা হয় না।
উদাহরণ:
| ইনপুট | খুঁজুন | প্রতিস্থাপন | string_replace_one(input, find, replacement) |
|---|---|---|---|
| "ফুবারফু" | "ফু" | "বাজ" | "বাজবারফু" |
| "é" | "é" | "ক" | "ক" |
| b"foobar" | b"o" | b"z" | b"fzoobar" |
ট্রিম
সিনট্যাক্স:
trim[T <: STRING | BYTES](input: T, values_to_trim: T) -> T
trim[T <: STRING | BYTES](input: T) -> T
বর্ণনা:
প্রদত্ত input শুরু এবং শেষ থেকে একটি নির্দিষ্ট সংখ্যক BYTES বা CHARS ছেঁটে ফেলে।
- যদি
values_to_trimপ্রদান করা না হয়, তাহলে হোয়াইটস্পেস অক্ষরগুলো ছেঁটে ফেলা হয়।
উদাহরণ:
যখন values_to_trim প্রদান করা হয় না:
| ইনপুট | trim(input) |
|---|---|
| "ফু" | "ফু" |
| b" foo " | b"foo" |
| "ফু" | "ফু" |
| "" | "" |
| " | "" |
| "\t ফু \n" | "ফু" |
| b"\t foo \n" | b"foo" |
| "\r\f\v foo \r\f\v" | "ফু" |
| b"\r\f\v foo \r\f\v" | b"foo" |
যখন values_to_trim প্রদান করা হয়:
| ইনপুট | values_to_trim | trim(input, values_to_trim) |
|---|---|---|
| "abcbfooaacb" | "এবিসি" | "ফু" |
| "abcdaabadbac" | "এবিসি" | "দাবাদ" |
| b"C1C2C3" | খ"সি১" | b"C2C3" |
| b"C1C2" | "ফু" | ত্রুটি |
| "ফু" | খ"সি১" | ত্রুটি |
Web
const result = await execute(db.pipeline() .collection("books") .select( field("name").trim().as("whitespaceTrimmedName") ) );
সুইফট
let result = try await db.pipeline() .collection("books") .select([ Field("name").trim(" \n\t").as("whitespaceTrimmedName") ]) .execute()
Kotlin
val result = db.pipeline() .collection("books") .select( field("name").trim().alias("whitespaceTrimmedName") ) .execute()
Java
Task<Pipeline.Snapshot> result = db.pipeline() .collection("books") .select( field("name").trim().alias("whitespaceTrimmedName") ) .execute();
পাইথন
from google.cloud.firestore_v1.pipeline_expressions import Field result = ( client.pipeline() .collection("books") .select(Field.of("name").trim().as_("whitespaceTrimmedName")) .execute() )
জাভা
Pipeline.Snapshot result = firestore .pipeline() .collection("books") .select(trim(field("name")).as("whitespaceTrimmedName")) .execute() .get();
এলটিআরআইএম
সিনট্যাক্স:
ltrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
ltrim[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
প্রদত্ত value শুরু থেকে একটি নির্দিষ্ট সংখ্যক BYTES বা CHARS ছেঁটে ফেলে।
-
to_trimপ্রদান করা না হলে, শুরুর দিকের অতিরিক্ত স্পেস অক্ষরগুলো ছেঁটে ফেলা হয়।
উদাহরণ:
যখন to_trim প্রদান করা হয় না:
| মূল্য | ltrim(value) |
|---|---|
| "ফু" | "ফু" |
| "ফু" | "ফু" |
যখন to_trim প্রদান করা হয়:
| মূল্য | ছাঁটাই করতে | ltrim(value, to_trim) |
|---|---|---|
| "aaabc" | "ক" | "বিসি" |
| "আবাকাবা" | "বা" | "কাবা" |
| "é" | "é" | "" |
আরটিআরআইএম
সিনট্যাক্স:
rtrim[T <: STRING | BYTES](value: T, to_trim: T) -> T
rtrim[T <: STRING | BYTES](value: T) -> T
বর্ণনা:
প্রদত্ত value শেষ থেকে একটি নির্দিষ্ট সংখ্যক BYTES বা CHARS ছেঁটে ফেলে।
- যদি
to_trimপ্রদান করা না হয়, তাহলে শেষের অতিরিক্ত স্পেস অক্ষরগুলো ছেঁটে ফেলা হয়।
উদাহরণ:
যখন to_trim প্রদান করা হয় না:
| মূল্য | rtrim(value) |
|---|---|
| "ফু" | "ফু" |
| "ফু" | "ফু" |
যখন to_trim প্রদান করা হয়:
| মূল্য | ছাঁটাই করতে | rtrim(value, to_trim) |
|---|---|---|
| "abccc" | "গ" | "ab" |
| "আবাকাবা" | "বা" | "অ্যাবাক" |
| "é" | "é" | "" |
বিভক্ত
সিনট্যাক্স:
split(input: STRING) -> ARRAY<STRING>
split[T <: STRING | BYTES](input: T, delimiter: T) -> ARRAY<T>
বর্ণনা:
একটি ডিলিমিটার ব্যবহার করে কোনো STRING বা BYTES ভ্যালুকে বিভক্ত করে।
STRINGএর ক্ষেত্রে ডিফল্ট ডিলিমিটার হলো কমা (,)। ডিলিমিটারটিকে একটি একক স্ট্রিং হিসেবে গণ্য করা হয়।BYTESএর ক্ষেত্রে, আপনাকে অবশ্যই একটি বিভাজক নির্দিষ্ট করতে হবে।খালি ডিলিমিটার দিয়ে স্প্লিট করলে
STRINGভ্যালুগুলোর জন্য ইউনিকোড কোডপয়েন্টের একটি অ্যারে এবংBYTESভ্যালুগুলোর জন্যBYTESএর একটি অ্যারে তৈরি হয়।একটি খালি
STRINGস্প্লিট করলে একটিARRAYফেরত আসে, যার মধ্যে একটিমাত্র খালিSTRINGথাকে।
উদাহরণ:
যখন delimiter প্রদান করা হয় না:
| ইনপুট | split(input) |
|---|---|
| "ফু, বার, ফু" | ["foo", "bar", "foo"] |
| "ফু" | ["ফু"] |
| ",ফু," | ["", "ফু", ""] |
| "" | [""] |
| b"C120C2C4" | ত্রুটি |
যখন delimiter প্রদান করা হয়:
| ইনপুট | বিভাজক | split(input, delimiter) |
|---|---|---|
| "ফু বার ফু" | " | ["foo", "bar", "foo"] |
| "ফু বার ফু" | "z" | ["ফু বার ফু"] |
| "এবিসি" | "" | ["a", "b", "c"] |
| খ"সি১,সি২,সি৪" | খ"," | [b"C1", b"C2", b"C4"] |
| b"ABC" | খ" | [b"A", b"B", b"C"] |
| "ফু" | খ"সি১" | ত্রুটি |