commit 24/09/2025
This commit is contained in:
@@ -35,6 +35,20 @@ class Somecodes {
|
||||
const val TB_threshold = GB_threshold * 1024.0
|
||||
val objectmapper = jacksonObjectMapper()
|
||||
|
||||
// regex for getting ann_id from Message, which is the number inside []
|
||||
private val ann_id_regex = Regex("\\[(\\d+)]")
|
||||
|
||||
/**
|
||||
* Extract ANN ID from a message string.
|
||||
* The ANN ID is expected to be a number enclosed in square brackets (e.g., "[123]").
|
||||
* @param message The message string to extract the ANN ID from.
|
||||
* @return The extracted ANN ID as an integer, or -1 if not found or invalid.
|
||||
*/
|
||||
fun Get_ANN_ID(message: String) : Int {
|
||||
val matchResult = ann_id_regex.find(message)
|
||||
return matchResult?.groups?.get(1)?.value?.toInt() ?: -1
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an object to a JSON string.
|
||||
* @param data The object to convert.
|
||||
|
||||
Reference in New Issue
Block a user