Modifying or Moving a Determinate Number of Characters In a Field

Hello Everybody,

If you would, please help me out with a tagging problem, which I am still unable to figure out by myself after several hours. What I wish to do, is the following:

Replace a determinate number of characters located at the end of the TITLE-field. In this case, the number of characters due for replacement are 4 numerals. These 4 numerals are to be replaced with the exact same numerals, but only now encased in curly braces.

I have tried ACTION-type: "Replace with regular expression" for this purpose, using the regular expression .{4}$ found on the forum. However, poor RE-skills hamper my best efforts at "Replace matches with" to produce the desired results.

How does one put those last 4 characters, say 1234 in the TITLE, with this: {1234}?

Thank you.

Perhaps like this:
$regexp('put those last 4 characters, say 1234',(.*) (\d+),$1 {$2})
->put those last 4 characters, say {1234}

Thank you, Ohrenkino.

The given regular expression did not deliver the expected results, and I apologize for not having expressed myself clearly. Perhaps the following examples of two titles are more to the point. The last 4 characters of the FIELD, highlighted below in bold, need to be replaced the way shown:

Example 1
Original Text: Just Out Of Reach 1952
Changed FIELD: Just Out Of Reach {1952}

Example 2
Original Text: We're Talking It Over 1959
Changed FIELD: We're Talking It Over {1959}

Then I don't know what you did.
$regexp('put those last 4 characters, say 1234',(.*) (\d+),$1 {$2})
delievers exactly the modification that you showed.
If you have a variable text, then you have to enter the source for the variable text first or name it, e.g.
$regexp(%title%,(.*) (\d+),$1 {$2})
will treat that what is found in TITLE.

Thank you, I will try again.

It is obvious that I am not applying your solution correctly, because this is the result of 3 tracks tested:

Application
image

Result
image

If you use scripting functions like $regexp() you have to use a function that allows a "Format string".
So you either change the action type to "Format value" for TITLE and then you can use the $regexp() function or you adapt the "Replace with regular expression" action to
Regular expression: (.*) (\d+)
Replace with: $1 {$2}

1 Like

Thank you very much for clarifying that, Ohrenkino, and thank you too, for consistently being here for us who need your expert assistance.

A very happy and prosperous New Year to you.

3 Likes

If you use scripting functions like $regexp() you have to use a function that allows a "Format string".
So you either change the action type to "Format value" for TITLE and then you can use the $regexp() function or you adapt the "Replace with regular expression" action to
Regular expression: (.*) (\d+)
Replace with: $1 {$2}

It did all work out precisely, thank you.

For my clarification, does the expression given above, namely (.*) (\d+) apply to numerals only, and if so, how does it have to be modified if it were 4 alphabetical characters to be replaced?

See the help on the syntax in regular expressions:

You will find that my suggestion did not take into account that there were 4 digits but it defined a pattern of any characters followed by a number of any length.
To do something with 4 characters, it could be easiest to use
....
but this would really include anything, even spaces, digits, punctuation.
So a closer look at what the pattern looks like would be of benefit.
To simply cut a number of characters from either end of a string (or even the middle) see the scripting functions:


like $left(), $cutleft() etc.

image

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.