Regex: How to remove last characters

  • Автор темы Автор темы mactron
  • Дата начала Дата начала

mactron

Пользователь
Регистрация
16.11.2014
Сообщения
93
Реакции
2
Баллы
8
I would like to remove last three characters and save first six characters in new variable.

2ef322ree

I have tried the code below, but that's the opposite of what I'm trying to do.

.(3)$

Here is the output in variable:

ree

Any suggestion? Thanks!
 
C#:
Развернуть Свернуть Копировать
string line = "2ef322ree";
return line.Substring(0, line.Length - 3);

or

C#:
Развернуть Свернуть Копировать
project.Variables["line"].Value = project.Variables["line"].Value.Substring(0, project.Variables["line"].Value.Length - 3);

or

C#:
Развернуть Свернуть Копировать
string line = project.Variables["line"].Value;
project.Variables["line"].Value  = line.Substring(0, line.Length - 3);
 
I my C# variable I'm getting value "ok"


C#:
Развернуть Свернуть Копировать
Execution of C# code of  Result:ok
 
This code works... May I ask you how to add variable instead of 2ef322ree? Thanks!

C#:
Развернуть Свернуть Копировать
string line = "2ef322ree";
return line.Substring(0, line.Length - 3);
 
OK , works like a charm now! Thank you
 
Also, you can do it with the standard action, see the screenshot below:
88316

What to search - .{3}$
What to replace with - leave empty
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)