Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
What type of regex would I need to grab from data

What regex would I need to get <t:1583277337:R> to then replace it so it display the proper information (in this case: 3 Years ago)

Why? I'm trying to use it on Discord where Discord automatically converts <t:1583277337:R> to the corresponding data, but the API retrieved data (below) doesnt automatically convert on Discord Embeds

Data

"bio": "๐–“๐–”๐–™ ๐–Š๐–›๐–Š๐–—๐–ž๐–”๐–“๐–Š ๐–œ๐–Ž๐–‘๐–‘ ๐–‡๐–Š๐–‘๐–Ž๐–Š๐–›๐–Š ๐–Ž๐–“ ๐–ž๐–”๐–š, ๐–‡๐–š๐–™ ๐–“๐–”๐–™ ๐–Š๐–›๐–Š๐–—๐–ž๐–”๐–“๐–Š ๐–’๐–†๐–™๐–™๐–Š๐–—๐–˜...\n\n\n<t:1583277337:R> <3"
almost 4 years ago ยท Santiago Trujillo
2 answers
Answer question

0

I won't give you the full solution, but here is the logic:

  1. explicit regex match for an <t:, in sequence
  2. digits of any amount
  3. explicit regex match for :R>

You can use this regex in String#replace. The replace method can accept a callback as its second argument for a more powerful parsing of a match. In this case, you can process the string in the replace callback to whatever text you need

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#parameters

almost 4 years ago ยท Santiago Trujillo Report

0

Example with group name:

<t:(?<timestamp>\d*):R>

Try it here https://regex101.com/

almost 4 years ago ยท Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!