Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regular expressions - range. #635

Open
Loli-Kyn opened this issue Dec 4, 2024 · 5 comments
Open

Regular expressions - range. #635

Loli-Kyn opened this issue Dec 4, 2024 · 5 comments

Comments

@Loli-Kyn
Copy link

Loli-Kyn commented Dec 4, 2024

Briefly:
I want a particular translation to apply to a particular number

Detail:
Almost every word can have a plural applied to it. This changes the ending. There are usually two variants “Day”, “Days”. In English, usually only an “S” is added at the end of the word. (I'm not very good at English and I don't know all the subtleties yet).
But in Russian there can be several endings depending on the dependent word. “1 день” “2 дня” ”5 дней
What I want to do:
Let's say in regular expressions there are digits from 1 to 20. I want to make a range of digits to which one of the given translations will be applied.

For example
The translation “A” will be applied to digit 1.
To digits from 2→4 the translation “B” will be applied.
To digits 5→20 the translation “D”.
А” = 1
デッキあと{{A}}枚必要 同カード{{B}}枚まで=We need another {{A}} card. Stack of cards {{B}}
В” = 2→4
デッキあと{{A}}枚必要 同カード{{B}}枚まで=Want more {{A}} cardS. Stack of cards {{B}}
Д” = 5→20
デッキあと{{A}}枚必要 同カード{{B}}枚まで=Need more {{A}} cardS. Stack of cards {{B}}

{{A}} and {{B}} is an included regular expression to the numbers so as not to duplicate the translation. You already know that.

I will duplicate the examples in Russian so that you can notice the difference in the endings.
"А" = 1
デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картА. Стак карт {{B}}
"В" = 2→4
デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картЫ. Стак карт {{B}}
"Д" = 5→20
デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} карт. Стак карт {{B}}

@Lmeks
Copy link
Contributor

Lmeks commented Dec 4, 2024

Those are substitutions, not regular expressions.
Make 3 regexes, the last one is
r:"^デッキあと([5-9]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Need more $1 cards. Stack of cards $2.

@Lmeks
Copy link
Contributor

Lmeks commented Dec 4, 2024

You might need to use \\ instead of \. idk

@Loli-Kyn
Copy link
Author

Loli-Kyn commented Dec 4, 2024

Those are substitutions, not regular expressions. Make 3 regexes, the last one is r:"^デッキあと([5-9]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Need more $1 cards. Stack of cards $2.

So if I want to apply this to all three options it would look like this?

"А"
r:"^デッキあと([1]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Нужна ещё $1 карта. Стак карт $2.`

"B"
r:"^デッキあと([2-4]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Нужно ещё $1 карты. Стак карт $2.`

"D"
r:"^デッキあと([5-9]|1[0-9]|20)枚必要 同カード(\d+)枚まで$"=Нужно ещё $1 карт. Стак карт $2.`

@Loli-Kyn Loli-Kyn closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2024
@Loli-Kyn Loli-Kyn reopened this Dec 4, 2024
@Lmeks
Copy link
Contributor

Lmeks commented Dec 4, 2024

"А"
r:"^デッキあと1枚必要 同カード(\d+)枚まで$"=Нужна ещё 1 карта. Стак карт $1.

"B"
r:"^デッキあと([2-4])枚必要 同カード(\d+)枚まで$"=Нужно ещё $1 карты. Стак карт $2.
There are several sites to test and learn regex online. XuA uses NET version.

@Loli-Kyn
Copy link
Author

Loli-Kyn commented Dec 4, 2024

Detail: Almost every word can have a plural applied to it. This changes the ending. There are usually two variants “Day”, “Days”. In English, usually only an “S” is added at the end of the word. (I'm not very good at English and I don't know all the subtleties yet). But in Russian there can be several endings depending on the dependent word. “1 день” “2 дня” ”5 дней” What I want to do: Let's say in regular expressions there are digits from 1 to 20. I want to make a range of digits to which one of the given translations will be applied.

For example The translation “A” will be applied to digit 1. To digits from 2→4 the translation “B” will be applied. To digits 5→20 the translation “D”. “А” = 1 デッキあと{{A}}枚必要 同カード{{B}}枚まで=We need another {{A}} card. Stack of cards {{B}} “В” = 2→4 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Want more {{A}} cardS. Stack of cards {{B}} “Д” = 5→20 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Need more {{A}} cardS. Stack of cards {{B}}

{{A}} and {{B}} is an included regular expression to the numbers so as not to duplicate the translation. You already know that.

I will duplicate the examples in Russian so that you can notice the difference in the endings. "А" = 1 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картА. Стак карт {{B}} "В" = 2→4 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} картЫ. Стак карт {{B}} "Д" = 5→20 デッキあと{{A}}枚必要 同カード{{B}}枚まで=Нужно еще {{A}} карт. Стак карт {{B}}

Thanks for your help.
I don't understand how to use regular expression validation sites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants