56
Views
12
Comments
Add a text or number on a specific position
Question
Application Type
Reactive
Service Studio Version
11.54.80 (Build 63648)
Platform Version
11.31.0 (Build 43948)

Good day! I have a problem, i am request a data to an api and the data on my api i want to add a text or integer on it on a specific position, is there a way that i can request and add a text or nnumbers on a specific position hope there is a way, for a mean time been trying the regex replace. but doesnt work on me. thanks! hope someone can see this

2019-01-31 08-54-57
André Costa
Champion

You can manipulate data returned from an API response before storing or displaying it. If you want to insert text or integers at a specific position in the string, you can use string manipulation functions rather than regex, as they are often simpler and more efficient in this context. 


When working with lists, you can access and manipulate the current position or a specific position in the list. Here's how to handle inserting or modifying values at specific positions in a list effectively:

Accessing and Modifying List Elements

  1. Accessing Current Item: When iterating over a list (for example, in a For Each loop), you can access the current item using:

    List.Current.VALUE

  2. Accessing a Specific Position: To access an element at a specific index in the list, you can use:

    List[POSITION].VALUE

    Here, POSITION is a zero-based index (e.g., 0 for the first item, 1 for the second item).

UserImage.jpg
jesu verso

do you have example on regex? maybe im using it wrong. thanks!

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

Jesu, so you tried RegEx but it doesn't work (yet). Maybe you share the work done and a bit more detailed description of what you try to achieve. That way someone can have a meaningful reply that maybe helps you. Right now there is little information you shared for someone to work with.

Regards,

Daniel

UserImage.jpg
jesu verso

sorry sir cant really share it due to its our school project thanks for understanding!

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

If it's a school project there's nothing keeping you from sharing, as it is not a business secret or something.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Jesu,

I don't understand what it is you want to achieve. You are talking about an API, but also about adding something at a certain position. Is it an API you consume or an API you expose? Is it the result of an API you want to handle, or do you need to output something that has been changed?

Also, you are talking about "insert text or integers at a specific position in the string", do you actually need to insert it, or overwrite the current content? Is it at a fixed position, or a position based on the current contents of the string? Why do you try to use regex? Have you looked into the built-in functions Index and Substr?

2021-01-28 10-02-59
Muhammad Mahmudul Hasan

Hi Jesu, 

If you know Index/Position then you can achieve it using build-in Substr(), Length() functions like below

Substr(OriginalString,0,5)+"text/value"+Substr(OriginalString ,9,Length(OriginalString))


If you're consuming API then apply in on "On Before Request"/"On After Response" based on your requirement. 

2025-04-10 12-15-03
Ankit Sheshkumar Shukla
AI Generated

Hi @jesu verso

Please find the below answer I hope this will work for you.

  • Deserialize the API Response: If the response is in JSON, use JSONDeserialize to parse it into a structure or record list so you can access specific fields.

  • String Manipulation: If you need to add text or numbers to specific positions in a string, consider using a combination of Substring, Concatenate, and Length functions:

    • Extract parts of the string up to the insertion point using Substring.
    • Add your text or number.
    • Concatenate it with the remainder of the original string.
  • Regex Usage: OutSystems supports regex, but it can be tricky. Instead of replacing, you might use regex to locate the position, then apply Substring and Concatenate around that position.

  • Using Text Functions: OutSystems has built-in functions for text handling, such as TextToInteger, IntegerToText, etc. Use these to ensure that you can add numbers or convert between types where needed.

This answer was AI-generated. Please read it carefully and use the forums for clarifications
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Please don't use ChatGPT to answer questions Ankit, it helps no-one!

2021-11-19 11-12-44
Rui Mendes

Hello @jesu verso,

Without you providing an explanation for your problem, we won't be able to help you. 

Can you give an example of what you need? 

I have this API request, and in a specific field, I need to make my modification. 

You are already dealing with Regex issues, and perhaps the solution doesn't even involve Regex... 

2024-09-17 12-24-07
Rammurthy Naidu Boddu
Champion

Hi, 

Regex is the only solution to take the text or number at any particular position.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.