Skip to content

Hw 08 RegExp#8

Open
bunin-av wants to merge 2 commits intomasterfrom
hw-08
Open

Hw 08 RegExp#8
bunin-av wants to merge 2 commits intomasterfrom
hw-08

Conversation

@bunin-av
Copy link
Copy Markdown
Owner

No description provided.

Comment thread RegExp/reg_exp-01.js Outdated
Comment thread RegExp/reg_exp-01.js Outdated
Comment thread RegExp/reg_exp-01.js
Comment thread RegExp/reg_exp-01.js
// `b\`la`
// (['"`])(\\.|[^\\'"`])*\1

let rexp = /(?<=“)(\\.|[^\\'"`”])*(?=”)|(?<=‘)(\\.|[^\\'"`’])*(?=’)/g
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему не использовал обратную ссылку?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ты запрешаешь внутри кавычки использовать кавычки другого типа - что не верно

Comment thread RegExp/reg_exp-01.js
ban: {a: 1}
}`;

let r = /((['"]?)\b[\w$]+\b\2): ([^\n,]+)(,?)$/gm
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не правильное решение(

Внутри кавычек в поле ключа могу быть любые символы, а не только \w$. Вот без кавычек - да. После символа : пробел не обязателен. Значение может содержать переводы строк или запятую

baz: [
  1, 2, 3, 4
]

Comment thread RegExp/reg_exp-01.js

let reg = /(?<=<)(\w+)\s*(.*?)(?=>)/gi
reg.exec(s); // ['div bla="foo"', 'div', 'bla="foo"'];
reg.exec(s); // ['div class=ban checked data-foo="baz"', 'div', 'class=ban', 'checked', 'data-foo="baz bar"'];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хм, я проверил твою регулярку и у меня она не работает(

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

Successfully merging this pull request may close these issues.

2 participants