0

示例字符串:-

<div class="ui-droppable" id="ParentDIV" style="width: 286pt; height: 212pt; background-color: #00752d; background-image: none;">
    <div class="be-canvas-grid" style="background-image: none">
        <div style="width: 200px; height: 50px; top: 77px; left: 162px; font-family: Arial; font-size: 12pt; color: rgb(0, 0, 0); overflow: hidden;" data-uid="2" class="be-component be-text  ui-draggable ui-droppable">
            <span>hello from simple text</span>
        </div>
        <div style="width: 161.567px; height: 39.5667px; top: 127px; left: 172px; font-family: Arial; font-size: 12pt; color: rgb(201, 87, 201); overflow: hidden;" data-uid="3" class="be-component be-text  ui-draggable ui-droppable">
            <span>{[C-FULLNAME:LC]}</span>
        </div>
        <div style="width: auto; height: auto; top: 196px; left: 216px;" data-uid="4" class="be-component be-image  ui-draggable">
            <img src="https://localhost/a/images/BarcodeType1.jpeg" data-qrstub="" alt="">
        </div>
        <div style="width: 200px; height: 50px; top: 6px; left: 12px; font-family: Arial; font-size: 12pt; color: rgb(201, 87, 201); overflow: hidden;" data-uid="5" class="be-component be-text  ui-draggable ui-droppable">
            <span>asd</span>
        </div>
    </div>
</div>

我想提取ParentDIV元素的样式属性,即宽度和高度。然后我想用我的值更新宽度和高度 css 属性。样式标签中的高度和宽度属性的顺序ParentDIV也可能会改变。

请建议正则表达式。我将在 C#.net 中进行此代码更改。

正则表达式可以借助在线工具http://www.gskinner.com/RegExr/构建。

4

0 回答 0