Coderja 1 month ago
Coderja #coding

Reverse Complex String Using Regex

Case

"m3u8|9a7171d4c402|a7dd|4d92|087c|1da7382b|com|google|https"

convert to

"https://google.com/1da7382b-087c-4d92-a7dd-9a7171d4c402/m3u8"

Code in Python

import re

# String asal
input_string = "m3u8|9a7171d4c402|a7dd|4d92|087c|1da7382b|com|google|https"

# Regex untuk memisahkan string berdasar karakter '|'
parts = input_string.split('|')

# Susun ulang menjadi format URL yang diinginkan
formatted_url = f"{parts[8]}://{parts[7]}.{parts[6]}/{parts[5]}-{parts[4]}-{parts[3]}-{parts[2]}-{parts[1]}/{parts[0]}"

print(formatted_url)

Result

https://google.com/1da7382b-087c-4d92-a7dd-9a7171d4c402/m3u8


Reverse Complex String using regex using Notepad ++

Example

m3u8|9a7171d4c402|a7dd|4d92|087c|1da7382b|com|google|https

To be

https://google.com/1da7382b-087c-4d92-a7dd-9a7171d4c402/m3u8

Regex

Find ^(m3u8)\|([0-9a-f]{12})\|([0-9a-f]{4})\|([0-9a-f]{4})\|([0-9a-f]{4})\|([0-9a-f]{8})\|(com)\|(google)\|(https)$
Replace With $9://$8.$7/$6-$5-$4-$3-$2/$1

Penjelasan

 Penjelasan komponen regex:
   - `(\w+)`: Menangkap segmen pertama (jenis file).
   - `([a-fA-F0-9]{12})|([a-fA-F0-9]{4})|([a-fA-F0-9]{4})|([a-fA-F0-9]{4})|([a-fA-F0-9]{8})`: Menangkap bagian dari angka heksadesimal yang akan disusun ulang dengan format `UUID`.
   - `(com|net|org|edu)`: Menangkap bagian domain (kom, net, org, edu).
   - `(\w+)`: Menangkap nama domain.
   - `(https?)`: Menangkap protokol (`http` atau `https`).

4. **Pada kolom "Replace with"**, masukkan template berikut:

   ```plaintext
$9://$8.$7/$6-$5-$4-$3-$2/$1
Cara Install C9 di Ubuntu

Cara Install C9 di Ubuntu

defaultuser.png
Coderja
1 month ago

Host Live Checker

defaultuser.png
Coderja
3 weeks ago
Video Thumbnail Generator

Video Thumbnail Generator

defaultuser.png
Coderja
1 month ago
How to move the post title below content wordpress

How to move the post title below content wordpress

defaultuser.png
Coderja
1 month ago
Bulk Rename File by Powershell

Bulk Rename File by Powershell

defaultuser.png
Coderja
1 month ago